Here's the complete source of an HTML page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head></head>
<body>
one<br>
two<br />
three<br></br>
four
</body>
</html>
Can anyone explain why an extra blank line appears between the "three" and the "four" when I view the page in IE8 or chrome?
I thought standards were supposed to make all browsers look the same and as far as I can see this page conforms to the XHTML transitional standard
Because the XHTML spec HTML Compatability Guidelines specify that br
must should be self closing. Apparently Chrome and IE8 are not follwing the spec and closing the open one for you, thus creating a second line break.
Some good answers already, but just to point out that HTML5 actually specifies that <br></br>
should be parsed as two <br>
start tags when parsing as text/html.
See An end tag whose tag name is "br"
in http://dev.w3.org/html5/spec/tokenization.html#parsing-main-inbody
Firefox 3.x only does this in quirks mode, but Firefox 4 does this in Standards mode as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With