Ian Hickson wrote:
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.
Presumably then this is yet another difference between
application/xhtml+xml and text/html.
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.
Thanks!
For reference, the current (and presumably as of now no longer valid)
behavior of html5lib is as follows:
#document
| <!DOCTYPE HTML>
| <html>
| <head>
| <style>
| "pre { border: solid; }"
| "
"
| <body>
| <pre>
| "
x
"
| "
"
- Sam Ruby