473,769 Members | 4,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

appropriate values for line-height


I have a style for a list:

dl { line-height: 1; margin-bottom: 1em; }

But the W3C CSS validator says:

Line: 124 Context : dl

Invalid number : line-height Parse Error - [empty string]

Why is "1" invalid? What "empty string"?

--

Haines Brown, KB1GRM

Nov 1 '06 #1
13 2700
Els
Haines Brown wrote:
I have a style for a list:

dl { line-height: 1; margin-bottom: 1em; }

But the W3C CSS validator says:

Line: 124 Context : dl

Invalid number : line-height Parse Error - [empty string]

Why is "1" invalid? What "empty string"?
It's an error in the validator - it thinks a unit is needed. If you
make it 1em instead of 1, it will stop complaining. According to the
specs, there is no need for the unit though:
http://www.w3.org/TR/CSS21/visudet.h...ef-line-height
--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Nov 1 '06 #2
Haines Brown <br****@teufel. hartford-hwp.comwrote:
>I have a style for a list:

dl { line-height: 1; margin-bottom: 1em; }
Rarely is it smart to alter the line-height, leave it alone.

--
Spartanicus
Nov 1 '06 #3
Scripsit Els:
It's an error in the validator - it thinks a unit is needed. If you
make it 1em instead of 1, it will stop complaining.
But that would be a wrong move, since the meaning is different. The reason
is that for 1em, the computed value is inherited, so you run into problems
if you ever change font size inside the element. For a pure number, that
number is inherited, which is fine.

Setting line-height: 1 isn't fine, though. It means that there is no spacing
between lines, i.e. the height of line is the size (height) of the font,
which generally means that ascenders may touch descenders of the previous
line. Reasonable values for line-height are typically from 1.2 to 1.3 or a
little higher, depending on the x-height.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Nov 1 '06 #4
On Wed, 01 Nov 2006 15:00:19 +0000, Spartanicus
<in*****@invali d.invalidwrote:
>Haines Brown <br****@teufel. hartford-hwp.comwrote:
>>I have a style for a list:

dl { line-height: 1; margin-bottom: 1em; }

Rarely is it smart to alter the line-height, leave it alone.

To be a bit more explicit: the most usual (sensible) reason for
adjusting line-height is to increase it to make subscripts and/or
superscripts more legible. Typically one would be looking at values of
1.4 and upwards. It's very rarely (never?) a good idea to set a value
smaller than that.

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Nov 1 '06 #5
Scripsit Stephen Poley:
>Rarely is it smart to alter the line-height, leave it alone.

To be a bit more explicit:
It is wise to be explicit about line-height, since browsers often have
rather small default values, and CSS specifications suggest even smaller,
like 1.1. A value of 1.2 (which is roughly what browsers tend to use as the
default) is typically suitable for common serif fonts, whereas sans-serif
fonts call for 1.25 or 1.3 for readability.
the most usual (sensible) reason for
adjusting line-height is to increase it to make subscripts and/or
superscripts more legible. Typically one would be looking at values of
1.4 and upwards. It's very rarely (never?) a good idea to set a value
smaller than that.
For subscripts and superscripts, it's probably best to set their font size
sufficiently small (around 70%) and declare their font as Verdana. This is a
bit questionable in principle, but it tends to solve the basic problems with
subscripts and superscripts.

Setting font-size: 1.4 is _not_ enough for getting even spacing between
lines when Arial is used, for example.

So it's quite the opposite. It's almost always a good idea to set
line-height for body to something reasonable, like 1.25.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Nov 1 '06 #6
Els
Jukka K. Korpela wrote:
Scripsit Els:
>It's an error in the validator - it thinks a unit is needed. If you
make it 1em instead of 1, it will stop complaining.

But that would be a wrong move, since the meaning is different. The reason
is that for 1em, the computed value is inherited, so you run into problems
if you ever change font size inside the element. For a pure number, that
number is inherited, which is fine.
I never knew that (never run into the problem), but you're right. It
is quite easily solved though, by setting the same line-height value
for such child elements. Means it's definitely not a good idea to use
on the body element, which is good to know, thanks :-)
Setting line-height: 1 isn't fine, though. It means that there is no spacing
between lines, i.e. the height of line is the size (height) of the font,
which generally means that ascenders may touch descenders of the previous
line. Reasonable values for line-height are typically from 1.2 to 1.3 or a
little higher, depending on the x-height.
All true, but it does depend on what it's used for. I can imagine that
for a single word or set of words, it may be desirable to set a very
low line-height. Not for paragraphs, but headings for example, or
other stuff that doesn't wrap.

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Nov 2 '06 #7
Scripsit Els:
>>It's an error in the validator - it thinks a unit is needed. If you
make it 1em instead of 1, it will stop complaining.

But that would be a wrong move, since the meaning is different. The
reason is that for 1em, the computed value is inherited, so you run
into problems if you ever change font size inside the element. For a
pure number, that number is inherited, which is fine.

I never knew that (never run into the problem), but you're right. It
is quite easily solved though, by setting the same line-height value
for such child elements.
It is more easily solved by using a pure number. You can write
* { line-height: 1.3em; }
but it is more natural to write
body { line-height: 1.3; }
I can imagine that
for a single word or set of words, it may be desirable to set a very
low line-height. Not for paragraphs, but headings for example, or
other stuff that doesn't wrap.
How can you know that it doesn't wrap? Would you assume some minimum canvas
width?

For a heading, the key issue is vertical margins. Their effect is generally
much greater than that of line-height. Besides, if you use "a very low line
height", you take unnecessary risks. If you set it to 1, for example, some
characters may actually extend above or below the element's box. The font
size is just _roughly_ equal to the distance from the highest ascender to
the lowest descender.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Nov 2 '06 #8
Els
Jukka K. Korpela wrote:
Scripsit Els:
>>>It's an error in the validator - it thinks a unit is needed. If you
make it 1em instead of 1, it will stop complaining.

But that would be a wrong move, since the meaning is different. The
reason is that for 1em, the computed value is inherited, so you run
into problems if you ever change font size inside the element. For a
pure number, that number is inherited, which is fine.

I never knew that (never run into the problem), but you're right. It
is quite easily solved though, by setting the same line-height value
for such child elements.

It is more easily solved by using a pure number. You can write
* { line-height: 1.3em; }
but it is more natural to write
body { line-height: 1.3; }
>I can imagine that
for a single word or set of words, it may be desirable to set a very
low line-height. Not for paragraphs, but headings for example, or
other stuff that doesn't wrap.

How can you know that it doesn't wrap? Would you assume some minimum canvas
width?
No, but there are still things that don't wrap.
One word lines for instance, or lines with just
a&nbsp;couple&n bsp;of&nbsp;wor ds glued together for whatever reason.
I'm not saying that it is common, or that it is probable, just that it
is possible.
For a heading, the key issue is vertical margins. Their effect is generally
much greater than that of line-height. Besides, if you use "a very low line
height", you take unnecessary risks. If you set it to 1, for example, some
characters may actually extend above or below the element's box. The font
size is just _roughly_ equal to the distance from the highest ascender to
the lowest descender.
Agree with all of that, just saying that I can still think of
situations where that is not an issue, and it can be desirable to set
a low line-height. Don't worry about it though, I still know that less
than 1.2 is not good for *most* situations :-)

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Nov 2 '06 #9
On 2006/11/01 21:42 (GMT+0100) Stephen Poley apparently typed:
On Wed, 01 Nov 2006 15:00:19 +0000, Spartanicus wrote:
>>Rarely is it smart to alter the line-height, leave it alone.
I used to think the same, but not any more.
To be a bit more explicit: the most usual (sensible) reason for
adjusting line-height is to increase it to make subscripts and/or
superscripts more legible. Typically one would be looking at values of
1.4 and upwards. It's very rarely (never?) a good idea to set a value
smaller than that.
I find anything significantly more than "normal" (usually 1.1-1.2)
line-height to be rather annoying most of the time that excessive
line-lengths are not employed. My default user stylesheet includes the
following:

html>body {font-size: medium !important; line-height: normal !important;}

This cuts down a bit on the annoyance, but not nearly as much as I'd
like due to pervasive iditis and classitis and repeated font
specification for virtually every type of element.

All that said, if the amount of space text takes up is an important part
of a design, line-height really should be explicitly set. Various fonts
have their own line-heights, as different font systems have different
ways of interpreting them. You can't expect your first font family
choice to have the same as the actual font used by your visitor,
particularly if the relative ages of the fonts you specify aren't
similar. Newer fonts tend to be unicode types, which generally provide
more available height for their diacritics than older versions of common
M$ fonts. http://mrmazda.no-ip.com/auth/Font/f...ansuni-lh.html
provides a way to see a little of this.
--
"Rejoice and be glad, because great is your reward in heaven."
Matthew 5:12 NIV

Team OS/2 ** Reg. Linux User #211409

Felix Miata *** http://mrmazda.no-ip.com/
Nov 2 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1325
by: Jack | last post by:
Hi, I have the following problem. I have a main data entry form which has a link to a detailed data entry form. The value of the link in the main form is the sum total of all the line items in the detailed form. The detailed form has fields to capture the individual line items like contracted service expense, travel expense etc. I am capturing the total of individual line items using session variables so
0
9169
by: Rob Dob | last post by:
Hi, I have a VS2003 C# asp.net project that has been converted into a VS2005 project. Everything seemed to work well until I make a modification to anything within the Component Designer window, i.e. I add a SQLCommand. At that point VS2005 changes my C# file to now load all Selectcommantext data from the resource file instead of the .aspx.cs file. then when I try and once again run my application I get the following error: looking...
3
24805
by: Elezar Simeon Papo | last post by:
Hello All, I have a tab separated input file (data.txt) in text format - the file looks like this SCHOOL DEPART1 DEPART2 DEPART3 Harvard Economics Mathematics Physics Stanford Mathematics Physics Berkeley Physics U.C.L.A Biology Genetics
53
4241
by: Alan Silver | last post by:
Hello, I understand the issue that tables should be used for tabular data and not for layout, but I would like some clarification as to exactly what constitutes tabular data. For example, if I have a form, in which the user is required to fill in various bits of information, then laying out with a table makes it easy. A basic example...
2
1518
by: programming | last post by:
I just would like to re-explain the problem i am having as i had not received any posts, so i might of explained in poorly. The problem i am having is NOT parse error related, more or less a problem in my logic. Ok , well what is happening is i am getting my values in member.txt fields ok from reading it, but when i attempted to write those values back to the member.txt file with updated string values, my member.txt file is cleared of...
4
14273
by: Phoe6 | last post by:
Hi, I have a configfile, in fact, I am providing a configfile in the format: Name: Foo Author: Bar Testcases: tct123
3
2842
by: Phoe6 | last post by:
Hi, Am starting a new thread as I fear the old thread which more than a week old can go unnoticed. Sorry for the multiple mails. I took the approach of Subclassing ConfigParser to support multiline values without leading white-spaces, but am struct at which position in _read I should modify to accomodate the non-leading whitespace based multiline values.
8
7125
by: Shawn Minisall | last post by:
I am trying to read a few lines of a file with multiple values, the rest are single and are reading in fine. With the multiple value lines, python says this "ValueError: too many values to unpack" I've googled it and it says that happens when you have too few or too many strings that don't match with the variables in number your trying to assign them too. Below are the lines in reading in:
4
3749
by: Chronictank | last post by:
Hi, as a bit of background (and seeing as it is my first post :)) i am a complete newbie at perl. I literally picked it up a week ago to do this project as it seemed like the best choice for a language to connect to a SQL database in a Unix envirment as well as script parsing so there is more than likely a ton of things i could have done a better way. I have been at this for 3 days now and cant for the life of me work out why the code is...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.