W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2014

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

From: Ian Hickson <ian@hixie.ch>
Date: Wed, 22 Jan 2014 22:59:52 +0000 (UTC)
To: Daniel Holbert <dholbert@mozilla.com>
Message-ID: <alpine.DEB.2.00.1401222250540.29201@ps20323.dreamhostps.com>
Cc: WHAT Working Group <whatwg@whatwg.org>
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.   `._.-(,_..'--(,_..'`-.;.'
Received on Wednesday, 22 January 2014 23:00:57 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:15 UTC