W3C home > Mailing lists > Public > www-style@w3.org > June 2008

Re: The <br> tag and the line-height CSS attribute.

From: Peter Moulder <Peter.Moulder@infotech.monash.edu.au>
Date: Tue, 24 Jun 2008 14:26:30 +1000
To: Francois Remy <fremycompany_pub@yahoo.fr>
Cc: CSS 3 W3C Group <www-style@w3.org>
Message-id: <20080624042630.GA3615@bowman.infotech.monash.edu.au>

On Mon, Jun 23, 2008 at 12:33:22PM +0200, Francois Remy wrote:

> When you have a <BR> that's alone on a line and when you apply a
> line-height attribute to it, should the line that he occupes change of
> height ?
>
> >> IE and Opera say "yes" (I think this is what developers want)
> >> Firefox and Safari say "no" (I think this is wat the spec want)
> 
> Test Code : 
> ==========
> A<br style="line-height: 1px;" /><!-- Normal line size -->
> <br  style="line-height: 1px;" /><!-- Line of 1px ? -->
> <br style="line-height: 1px;" />B<!-- Normal line size -->

[I'm not sure that you intended to include that last <br/> element,
 which creates a second "empty" line before the B.]

> What's the good answer ? Should that not appear in the spec ?

In http://www.w3.org/TR/CSS21/visudet.html#line-height, rule 3 is
undefined if there are no inline boxes, which is arguably the case here.

However, even if we do take the position that there are no inline boxes
on the second line, I'd say that rule 4's provision applies:

# 4. If the resulting height is smaller than the minimal height of line
#    boxes for this block, as specified by the 'line-height' property,
#    the height is increased to be that minimal height.

Thus, based on this section, I believe that the height of the second
line should be the length corresponding to the line-height property of
the containing block [at least if that is greater than 1px],
corresponding to what you report that Firefox and Safari do for the
above example. 


However, since writing the above, I've found this text in 9.4.2:

# Line boxes that contain no text, no preserved white space, no inline
# elements with non-zero margins, padding, or borders, and no other
# in-flow content (such as images, inline blocks or inline tables), and
# don't end with a line feed must be treated as zero-height line boxes.
# For the purposes of margin collapsing, this line box must be ignored.

This contradicts the claim earlier in that section that

# The height of a line box is determined by the rules given in the
# section on line height calculations.

(It is a contradiction because the paragraph "Line boxes that contain no
text..." is not in the referenced section, and yet the rules of the
referenced section do not determine that the height of the line box in
the empty case is zero as that paragraph specifies.)

I suggest that 10.8 be changed to give the "empty line-box" rule first,
followed by "Otherwise:" and then the existing list.  (In particular, it
should be clear that rule 4 ("if the resulting height") does not apply
to empty line boxes.)


Back to the example in question: the height of the second line depends
on whether it is considered to contain any inline boxes or not.
I haven't checked the spec thoroughly; I'll let others comment on that.
(FWIW, my current belief is that it doesn't contain any inline boxes,
and thus that the second line should have zero height.)

pjrm.
Received on Tuesday, 24 June 2008 04:27:09 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:07 GMT