Why is <br/"> different from </br> in XHTML?
Here is the full source of the 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 someone explain why there is an extra blank line between “three” and “four” when I view the page in IE8 or chrome?
I thought that the standards were supposed to make all browsers the same, and as far as I can see, this page is in compliance with the XHTML transition standard
There are already some good answers, but only to indicate that HTML5 actually indicates that <br></br> should be parsed as two <br> tags when parsing text / html.
See An end tag whose tag name is "br" at http://dev.w3.org/html5/spec/tokenization.html#parsing-main-inbody
Firefox 3.x only does this in quirks mode, but Firefox 4 does it in standard mode.
An additional line between three and four is that there are two <br /> tags between them. The first moves the content to the next line, and the second moves it another line down. This is the expected behavior.
Edit Sorry, this was strictly for the following.
In addition, <br /> tags are empty tags and therefore must be closed. Because of this, I don’t think that <br> technically compatible with xhtml. It should be <br /> .
In XHTML - they are the same - and if you serve the document as application/xhtml+xml , there will be no difference in browsers (provided that the browser supports XHTML, IE 8 and below do not).
If you serve the document as text/html , it will be treated as HTML, not XHTML, but in HTML <br> is an element where the end tag is not allowed. If you include an explicit end tag, some browsers will erroneously assume that </br> is a <br> tag.
There are various additional rules that must be followed if you claim that your XHTML is text / html. They are described in the compatibility guidelines . This item is for items that can never have content .
Working as text / html was a hack designed for short-term evaluation when switching to XHTML. Various things (including the lack of support from Microsoft) prevented this transition from completing, and the HTML 5 movement abandoned the idea and returned to optional and forbidden end tags (but adding to /> as syntactic sugar).