The specification states that:
Some HTML element types allow authors to omit end tags (eg, the P and LI element types).
It:
Please consult the SGML standard for information about rules governing elements (eg, they must be properly nested, an end tag closes, back to the matching start tag, all unclosed intervening start tags with omitted end tags (section 7.5.1), etc.).
Applies to elements that may have missing end tags.
If you look at P , you will see:
Start tag: required ; end tag: optional
So when you use this:
<DIV> <P>This is the paragraph. </DIV>
The P element will be automatically closed.
But if you look at the EM spec, you will see:
Start tag: required ; end tag: required
So, this auto close rule is invalid because HTML is invalid.
Curiously, all browsers presented the same behavior with such invalid HTML.
source share