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

On Wed, Jan 22, 2014 at 1:51 PM, Daniel Holbert <dholbert@mozilla.com> wrote:
> Hi folks,
>
> 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.

We talked this over in the CSSWG meeting, and came up with a proposal
for non-magical styling that is still very close to current behavior
in all browsers:

br {
  display-box: contents;
  content: "\A";
  white-space: pre;
}

This lets you adjust the size of the <br> with text-styling
properties, and use display:none to hide it entirely.  Any/all of
these can be set to !important if necessary for compat.

~TJ

Received on Wednesday, 29 January 2014 18:58:45 UTC