HTML parser
The part of the browser that reads HTML text and builds the DOM tree from it, one token at a time.
In more detail
Parsing runs in stages: bytes are decoded into characters, a tokenizer turns characters into tokens, and a tree builder turns tokens into DOM nodes. The HTML parser never gives up on bad markup; the standard defines exactly how every error is repaired. A synchronous script tag pauses the parser until the script has downloaded and run.
Related terms
- HTML tokenization — The parsing step that splits a stream of characters into meaningful pieces called tokens, such as a start tag, an end tag or a run of text.
- tree construction — The parsing stage that takes tokens from the tokenizer and assembles them into the DOM tree, tracking which elements are still open.
- DOM — The tree of objects a browser builds from a web page, which scripts read and change to update what is on screen.
- HTML error recovery — The HTML parser's standard rules for repairing broken markup, such as unclosed tags, instead of refusing to show the page.
- preload scanner — A secondary parser that skims ahead through the HTML while the main parser is blocked and starts downloading scripts, stylesheets, fonts and images early.
Taught in
- HTML Parsing, Tokenization And The Document Object Model (DOM) — Frontend Architecture & Web Platform
- Critical Rendering Path: Preload, Prefetch And Scripts — Frontend Architecture & Web Platform