Xah Lee, 2006-07-29
This is a oddity. In the following pink block, the red lines should start on a line by itself (instead of continue with the blue), because the pink block is «pre».
What you gon' do with all that junk? All that junk inside your trunk? I'ma get, get, get, get, you drunk, Get you love drunk off my hump. They buy me all these ices.
Safari (2.0.4) and FireFox (1.5.0.5 Mac) renders them in a single line. Opera (9.00 Mac) and iCab (β352 (3.0.1)) and Windows Internet Explorer 6 renders them as expected. (however, IE6 does not honor the «display:table» CSS.)
According to http://www.w3.org/TR/html4/appendix/notes.html#notes-line-breaks, quote: «SGML (see [ISO8879], section 7.6.1) specifies that a line break immediately following a start tag must be ignored, as must a line break immediately before an end tag. This applies to all HTML elements without exception.».
This may explain this behavior. However, this is indeed a very odd spec. How is one suppose to break the lines inside «pre» in the above situation? Adding «br» is illegal, and adding another line break doesn't help.
In the following block, there are 2 line breaks at the end of the blue lines. But Safari and FireFox still have the redlines start immediate after the blue.
What you gon' do with all that junk? All that junk inside your trunk? I'ma get, get, get, get, you drunk, Get you love drunk off my hump. They buy me all these ices.
Further, if this is a SGML spec, then one'd suspect that XML/XHTML doesn't have this exception. Here's the test page for xhtml version. linebreak_after_tag.xhtml. Still, FireFox and Safari get them into one single line, while iCab and Opera does fine.
If one removes the «display:table», then all browsers renders the «pre» as expected.
Related essays: