[whatwg] HTML spec incorrectly suggests that <br> can have its rendering changed with CSS

Ian Hickson ian at hixie.ch
Wed Jan 22 14:59:52 PST 2014


On Wed, 22 Jan 2014, Daniel Holbert wrote:
> 
> Boris Zbarsky and I ran across a "not reflecting reality" issue in the
> WHATWG HTML spec.
> 
> The spec currently defines the rendering of the <br> element as follows:
>  # br { content: '\A'; white-space: pre; }
> Source:
> http://www.whatwg.org/specs/web-apps/current-work/multipage/rendering.html#phrasing-content-1
> 
> This CSS implies that <br>'s rendering could be customized by CSS, which 
> in practice (in the browsers that I tested[1]) is not actually the case.

Yeah, this is intentional. The spec is trying to point the way for 
browsers to go in. :-)

Right now, 'content' isn't even defined as applying to elements; the HTML 
spec is relying on somewhat well-established theory for future expansion 
of the 'content' property. The idea is that, on the long term, we can 
"explain" <br> in terms of regular CSS. (I similarly hope we can do this 
with form controls, but form controls right now have behaviours that can't 
even be explained by theoretical CSS, as far as I can tell.)


> In particular: given the spec's CSS quoted above, you might expect that
> perhaps an author could set...
>    "white-space: nowrap"
> ... on a <br> element, to neuter the linebreak. That doesn't work,
> though -- the <br> still triggers a linebreak.

Right. If allowing this isn't Web compatible, then I guess we'll have to 
change.


> Similarly, you might also
> expect to be able to customize the 'display' or 'height'/'width' or
> 'background' properties, but in practice, none of those have any effect
> on <br> in modern browsers.

In isolation, 'height' and 'width' would have no effect (they don't apply 
to display:inline elements) and 'background' would not have a visible 
effect (the element has no effective width). 'display', though, in theory, 
should have an effect. If allowing this isn't Web compatible, then I guess 
we'll have to change.

My hope is that we can limit what needs to have no effect, so that on the 
long term <br> becomes less and less magical. But naturally this depends 
on what is Web compatible.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list