3 ms·
In HTML you can leave out the end tag in cases where they can be unambiguously inferred, like: <p>First paragraph<p>Second paragraph</p> P-element can't be
by goto11 6y ago
In HTML you can leave out the end tag in cases where they can be unambiguously inferred, like:
<p>First paragraph<p>Second paragraph</p>
P-element can't be nested, so a <p> will automatically close the previous p-element.
But this also means it is necessary to indicate the tag name in the closing tag. For example this would be ambiguous:
<div><p>Hello</>
It cannot be inferred if it is the div or p which is closed.
XML is of course different. Since all element have to be explicitly closed, repeating the tag-name in the close tag is in principle superfluous. I think it makes it easier to read though, at the cost of more effort to write.