logoalt Hacker News

jakelazaroffyesterday at 3:43 PM2 repliesview on HN

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>

Replies

xg15yesterday at 3:57 PM

Ah, that's true. I think the WHATWG discouraged the syntax, so this might be why.

ricardobeatyesterday at 4:12 PM

This is really easy to detect though, unlike arbitrary rules on what belongs on the inside of an unclosed tag.