2 ms·
> HTML in the wild can be rather wild. One easy way to get an idea of how complicated this can be is checking out the parsing algorithm in the HTML5 spec [1] (
by ufo 14y ago
> HTML in the wild can be rather wild.
One easy way to get an idea of how complicated this can be is checking out the parsing algorithm in the HTML5 spec [1] (section 12).
To start the complexity, HTML is not XML and not all tags are created equal. Void elements like <img> and <br> don't have matching close tags and contents for things like <textarea> and <script> are treated as text (you can't nest more tags inside). Then you have the issue of javascript being able to call document.write at HTML-parsing times, something you need to hope doesn't happen or parsing becomes intractable. Finally, There is a vast number of rules and special cases that kick off when you have missing or mis-nested tags or tags being put in the wrong places.
[1] http://www.whatwg.org/specs/web-apps/current-work/multipage/ http://www.whatwg.org/specs/web-apps/current-work/multipage/