liveBook · Manning

HTML

As explained in Secrets of the JavaScript Ninja, Third Edition

The standard markup language for structuring documents and content on the web.

HTML is the blueprint a browser parses to build a page’s initial user interface. The resulting DOM is related to HTML, but it is a separate representation: the browser can even correct errors in the markup while constructing it. section 4.2.1 section 4.5

During page construction:

  • The browser parses HTML element by element, representing each element as a node in a tree. Nodes have one parent, may have multiple children, and can share a parent as siblings. section 4.2.1
  • When the parser reaches a script tag, it normally pauses parsing to run the script, which can access and modify the DOM. The async, defer, and module attributes can override this default behavior. section 4.2

When the browser repairs markup

A paragraph placed inside the head is invalid because the head is for page information, not page content. The browser silently constructs a DOM with the paragraph in the body instead. section 4.2.1

Figure 4.2 The page-building phase starts when the browser receives the code of the page. The process of parsing HTML to build the DOM is interrupted whenever JavaScript code runs.

The diagram traces page construction and shows where JavaScript interrupts HTML parsing. section 4.2

How Secrets of the JavaScript Ninja, Third Edition covers it

How deep it goes
Explains element parsing, DOM tree relationships, browser correction, and script-triggered pauses in parsing.
Examples
Uses a paragraph misplaced in the head and a diagram of parsing interrupted by JavaScript.
What you can do after
Understand how browsers turn HTML into a DOM and how scripts interact with that construction.
How it connects
Connects HTML to DOM construction, JavaScript DOM updates, and JSX.

Also explained in

Compare how 16 books explain HTML →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secrets of the JavaScript Ninja, Third Edition. The section links point to the parts of the book it draws on.