3 ms·
The inert self closing syntax is misleading, though, because if you use it for a non-void element then whatever follows will be contained within the tag. e.g.
by jakelazaroff 9mo ago
The inert self closing syntax is misleading, though, because if you use it for a non-void element then whatever follows will be contained within the tag.
e.g. how do you think a browser will interpret this markup?
<div />
<img />
A lot of people think it ends up like this (especially because JSX works this way):
<div></div>
<img>
but it's actually equal to this:
<div>
<img>
</div>
- xg15 9mo agoAh, that's true. I think the WHATWG discouraged the syntax, so this might be why.
- ricardobeat 9mo agoThis is really easy to detect though, unlike arbitrary rules on what belongs on the inside of an unclosed tag.