News for hackers. Stuff that matters.
Re:Stop ‘Using’ “Useless” ‘“‘Quotes’”’ by chrismorgan on Tuesday July 21, 2020 @01:39PM (#23908945)
Yeah, that’s not how it works at all (or has ever worked). It’s defined as a state machine and parses it code point by code point. And since HTML5, it defines how all inputs must be parsed: if two browsers ever parse any HTML document differently, there’s a bug in at least one of them. You can write non-conformant documents, but browsers will still all parse them identically.

Your example is equivalent to <div class="pants" shirts="" id="small">. This may show your error in expecting that it look backwards: no attribute names are considered special, an attribute value is concluded by its closing quote or by characters like space, and attributes don’t have to have values (there are plenty of boolean attributes, which are the most common cases where people omit the ="").

The HTML grammar really isn’t conducive to lexing.

If you’re interested in how it all actually works, I find how the HTML spec defines its parser very approachable.

There are no comments on this comment yet.