I think this quote from the HTML5 Standard provides the answer:
3.2.2.2 Void Elements
The term void elements is used to designate elements that must be empty. These requirements only apply to the HTML syntax. In XHTML, all such elements are treated as normal elements, but must be marked up as empty elements.
These elements are forbidden from containing any content at all. In HTML, these elements have a start tag only. The self-closing tag syntax may be used. The end tag must be omitted because the element is automatically closed by the parser.
HTML Example:
A void element in the HTML syntax. This is not permitted in the XHTML syntax.
<hr>
Example:
A void element using the HTML- and XHTML-compatible self-closing tag syntax.
<hr/>
XHTML Example:
A void element using the XHTML-only syntax with an explicit end tag. This is not permitted for void elements in the HTML syntax.
<hr></hr>
In other words:
- Invalid HTML5:
<IMG></IMG>
- Valid HTML5:
<IMG>
, <IMG/>
And while HTML forbids certain closing tags, xhtml requires them:
- Invalid XHTML:
<img>
- Valid XHTML:
<img></img>
or <img/>
Other elements that are forbidden from having a closing tag in HTML:
Element |
Valid HTML |
Valid XHTML |
AREA |
<AREA> |
<AREA></AREA> |
BASE |
<BASE> |
<BASE></BASE> |
BASEFONT |
<BASEFONT> |
<BASEFONT></BASEFONT> |
BR |
<BR> |
<BR></BR> |
COL |
<COL> |
<COL></COL> |
FRAME |
<FRAME> |
<FRAME></FRAME> |
HR |
<HR> |
<HR></HR> |
IMG |
<IMG> |
<IMG></IMG> |
INPUT |
<INPUT> |
<INPUT></INPUT> |
ISINDEX |
<ISINDEX> |
<ISINDEX></ISINDEX> |
LINK |
<LINK> |
<LINK></LINK> |
META |
<META> |
<META></META> |
PARAM |
<PARAM> |
<PARAM></PARAM> |
The fact that HTML forbids certain closing tags, while XHTML requires them is XHTML's problem. If you're writing HTML, you follow the HTML rules.
At the same time, browers gave up trying to enforce the standards, because everyone gets it wrong. It's not obvious:
- that
</BR>
is forbidden
- that
</P>
is optional
- and
</SPAN>
is required
And then xhtml came along, with its XML rule that every element must have a closing tag, and people just assumed that HTML was the same thing. So the standards gave up, and were later revised to throw up their hands to the reality.
<br/>
or<br />
they will eventually be converted to<br>
by the browser. – Ganny