[whatwg] Pre element question

On Fri, 19 Jan 2007, Sam Ruby wrote:
>
> People often code things like the following:
> 
> <pre>
> one
> two
> three
> </pre>
> 
> Visually, this ends up looking something like
> 
> +-------+
> |       |
> | one   |
> | two   |
> | three |
> +-------+
> 
> with the following CSS rule:
> 
> pre { border: solid 1px #000; }
>
> [in standards mode]

I couldn't reproduce this. In Firefox trunk, with:

http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%3Cstyle%3Epre%20%7B%20border%3A%20solid%3B%20%7D%3C/style%3E%0A%3Cpre%3E%0Ax%0A%3C/pre%3E

...I get the leading newline dropped.

If it did do it, in HTML4, it would have been a stardards mode bug (bug 
2750, which I filed back in 1999).

In HTML5, we're dropping that requirement, since everyone ignores it. 
However, we will, as you point out, have to introduce a special behaviour 
for a newline at the start of a <pre> element. IE actually does it for 
more than just the <pre> element (e.g. it does it for <p>, though not 
<span>) but compatibility with the Web only seems to require it for <pre> 
since that's all that the other browsers do it for.

Fixed.

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

Received on Friday, 19 January 2007 16:08:12 UTC