Skip to content

Instantly share code, notes, and snippets.

@qnighy
Last active May 4, 2022 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qnighy/9b022b68e1b92908c6b81d61603fadda to your computer and use it in GitHub Desktop.
Save qnighy/9b022b68e1b92908c6b81d61603fadda to your computer and use it in GitHub Desktop.
HTML basic parser states
<!-- initial -->
<!-- Ignored: whitespace -->
<!-- Relocated: comment -->
<!DOCTYPE html>
<!-- before html -->
<!-- Ignored: whitespace -->
<!-- Ignored: DOCTYPE -->
<!-- Ignored: end tags other than </head>, </body>, </html>, </br> -->
<!-- Relocated: comment -->
<html>
<!-- before head -->
<!-- Allowed: comment -->
<!-- Ignored: whitespace -->
<!-- Ignored: DOCTYPE -->
<!-- Ignored: end tags other than </head>, </body>, </html>, </br> -->
<!-- Merged retrospectively: <html> -->
<head>
<!-- in head -->
<!-- Allowed: whitespace -->
<!-- Allowed: comment -->
<!-- Allowed: <base>, <basefont>, <bgsound>, <link>, <meta>, <noframes>, <noscript>, <script>, <style>, <template>, <title> -->
<!-- Ignored: DOCTYPE -->
<!-- Ignored: end tags other than </head>, </body>, </html>, </br> -->
<!-- Merged retrospectively: <html> -->
</head>
<!-- after head -->
<!-- Allowed: whitespace -->
<!-- Allowed: comment -->
<!-- Ignored: DOCTYPE -->
<!-- Merged retrospectively: <html> -->
<!-- Inserted retrospectively in the head: <base>, <basefont>, <bgsound>, <link>, <meta>, <noframes>, <script>, <style>, <template>, <title> -->
<!-- Ignored: end tags other than </body>, </html>, </br> -->
<body>
<!-- in body -->
<!-- Allowed: text -->
<!-- Allowed: comment -->
<!-- Allowed or ignored: any tags other than </body> and </html> -->
<!-- Ignored: DOCTYPE -->
<!-- Merged retrospectively: <html>, <body> -->
<!-- If <frameset> comes directly after <body>, it replaces the body. -->
</body>
<!-- after body -->
<!-- NOTE: the body is still on the stack -->
<!-- Relocated in the body: whitespace -->
<!-- Relocated in the body: comment -->
<!-- Ignored: DOCTYPE -->
<!-- Merged retrospectively: <html> -->
<!-- Goes back to body: text other than whitespace -->
<!-- Goes back to body: tags other than <html> and </html> -->
<!-- Alternatively, instead of the body, the following element may come here -->
<frameset>
<!-- in frameset -->
<!-- Allowed: whitespace -->
<!-- Allowed: comment -->
<!-- Allowed: <frameset>, <frame>, <noframes> -->
<!-- Merged retrospectively: <html> -->
<!-- Ignored: DOCTYPE -->
<!-- Ignored: tags other than <html>, <frameset>, <frame> and <noframes> -->
</frameset>
<!-- after frameset -->
<!-- Allowed: whitespace -->
<!-- Allowed: comment -->
<!-- Allowed: <noframes> -->
<!-- Merged retrospectively: <html> -->
<!-- Ignored: DOCTYPE -->
<!-- Ignored: tags other than <html> and <noframes> -->
</html>
<!-- after after body -->
<!-- NOTE: the <html> and the <body> are still on the stack -->
<!-- Relocated in the body: whitespace -->
<!-- Relocated in the body: comment -->
<!-- Ignored: DOCTYPE -->
<!-- Merged retrospectively: <html> -->
<!-- Goes back to body: text other than whitespace -->
<!-- Goes back to body: tags other than <html> -->
<!-- Or, after after frameset -->
<!-- NOTE: the <html> is still on the stack -->
<!-- Relocated in the <html>: whitespace -->
<!-- Relocated in the <html>: comment -->
<!-- Relocated in the <html>: <noframes> -->
<!-- Ignored: DOCTYPE -->
<!-- Ignored: text other than whitespace -->
<!-- Ignored: tags other than <html> -->
<!-- Merged retrospectively: <html> -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment