473,399 Members | 3,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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 2658
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*****@invalid.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&nbsp;of&nbsp;words 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
Scripsit Felix Miata:
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.
According to typographers, the line height should be selected according to
the properties (especially x height) of the font and the line length and the
horizontal margins in a balanced manner. This is an impossible equation in
web authoring, since users or their browsers may override anything we say in
CSS, e.g. override our font-family setting but nothing else. Everything is a
compomise then, and we should aim at something _reasonable_.

Too small line height reduces readability, whereas too large line height
(within reasonable limits) is mostly just an esthetic matter. Thus, I would
take my chances in setting line-height to something around 1.25 to 1.3 if I
set font-family to Arial, for example. Maybe we shouldn't set the font
family at all, but most authors do.
My default user stylesheet includes the
following:

html>body {font-size: medium !important; line-height: normal
!important;}
It's your privilege to put anything you like in your user style sheet, but
that's a different issue. I find it odd, though, to enforce values like
medium and normal there. If you think that your browser's current
interpretations for them are really the best for you, why don't you use the
physical values in pixels or points?
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.
So why don't you set
* { line-height: normal !important; }
if that's what you want? The font size issue is different, but you could set
the font size of _all_ elements too.

From the authoring point of view, though, the point is that most users don't
set line height and have no idea of even being able to do it. So you should
set it to a value that matches your other settings and common defaults in
browsing.

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

Nov 3 '06 #11
Wed, 1 Nov 2006 19:49:26 +0200 from Jukka K. Korpela
<jk******@cs.tut.fi>:
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.
And the underlining of links may disappear depending on ascenders in
the following line.

Example:
http://www.tc3.edu/instruct/sbrown/stat50/sked.htm
and in Print Preview look at the entry for Nov 28.

That's my page, as it happens. I've known for some time that I need
to fix the line-height in the print style sheet, but I keep
forgetting. Now I have an excuse: I have to leave the example there
for a few days. :-)

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2.1 spec: http://www.w3.org/TR/CSS21/
validator: http://jigsaw.w3.org/css-validator/
Why We Won't Help You:
http://diveintomark.org/archives/200..._wont_help_you
Nov 5 '06 #12
Sun, 5 Nov 2006 15:41:00 -0500 from Stan Brown
<th************@fastmail.fm>:
Wed, 1 Nov 2006 19:49:26 +0200 from Jukka K. Korpela
<jk******@cs.tut.fi>:
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.

And the underlining of links may disappear depending on ascenders in
the following line.

Example:
http://www.tc3.edu/instruct/sbrown/stat50/sked.htm
and in Print Preview look at the entry for Nov 28.

That's my page, as it happens. I've known for some time that I need
to fix the line-height in the print style sheet, but I keep
forgetting. Now I have an excuse: I have to leave the example there
for a few days. :-)
By the bye, my CSS specifies line-height:normal, and that's obviously
not large enough.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2.1 spec: http://www.w3.org/TR/CSS21/
validator: http://jigsaw.w3.org/css-validator/
Why We Won't Help You:
http://diveintomark.org/archives/200..._wont_help_you
Nov 5 '06 #13
On 2006/11/03 07:19 (GMT+0200) Jukka K. Korpela apparently typed:
Scripsit Felix Miata:
>My default user stylesheet includes the
following:
>html>body {font-size: medium !important; line-height: normal
!important;}
I find it odd, though, to enforce values like
medium and normal there. If you think that your browser's current
interpretations for them are really the best for you, why don't you use the
physical values in pixels or points?
When my eyes are tired and I have to boost the default to get through
the rest of the day, the line-height automatically follows right along.
Also, I somethings put that same elementary stylesheet on the computers
of others, and would hardly expect most users I've provided it to to
remember anything about where it is, much less how or when they might
need to change it.
>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.
So why don't you set
* { line-height: normal !important; }
if that's what you want?
You should try it sometime and see what happens on the gazillion web
sites that set container heights in px or use absolute positioning.
The font size issue is different, but you could set
the font size of _all_ elements too.
Iditis and classitis make such simplicity minimally effective. I used to
do that, but simply turning off site styles tends to be easier and more
effective.
--
"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 5 '06 #14

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

Similar topics

0
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...
0
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...
3
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...
53
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...
2
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...
4
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
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...
8
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...
0
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...

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.