HTML structure & DOM explainer
Paste HTML and read the tree the HTML parser builds from it: every element, text node and comment with its line, the elements the parser created without a tag (html, head, body, tbody), the end tags it supplied, the formatting elements it split and the content it moved out of a table, with the document mode (quirks or not) and every parse error by the standard's own code and position. Then the findings: the DOCTYPE, the language, the title, the encoding, images without alternative text, links and buttons with no name, heading jumps, duplicate ids, controls without labels, obsolete elements and attributes, each tied to a sentence of the HTML Standard or WCAG 2.2. Parsing only: no script runs, nothing is fetched, nothing is rendered.
Web & HTTPNo-quirks mode. 14 elements, 6 text nodes and no comments, 6 levels deep, from one line of source.
One parse error. Findings: one error, 2 warnings, 3 notes.
What the document declares
- DOCTYPE
<!DOCTYPE html>- mode
- no-quirks The standards mode: <!DOCTYPE html> or an equivalent was found first.
- title
- T
- lang
en- charset
- absent
- most used
li2body1br1div1head1html1img1table1tbody1td1title1tr1
The tree the parser built
Each row is one node, indented by depth, with the line of its tag in the source. One element was created by the parser without a tag, 3 end tags were supplied by the parser, no element was split, one node was moved out of a table; no whitespace-only text node is left out of the list.
- 1
<!DOCTYPE html> - 1
<html lang="en"> - 1
<head> - 1
<title> - 1“T”
- 1
<body> - 1
<ul> - 1
<li>end supplied - 1“one”
- 1
<li>end supplied - 1“two”
- 1“stray”moved
- 1
<table> - ·
<tbody>created - 1
<tr> - 1
<td> - 1“x”
- 1
<br>void - 1
<div>end supplied - 1“text”
- 1
<img src="a.png">void
A dot in the line gutter marks a node with no source position: the parser created it. The pills say what the parser did: created (no tag in the source), end supplied (no end tag in the source), void (never has an end tag), self-closing (foreign content written with />), piece n (one source element split into several), moved (foster-parented before a table), obsolete (section 16.2 of the standard), template (lives in a template's content, not in the document).
One parse error
| line:col | code | what the standard says |
|---|---|---|
| 1:132 | non-void-html-element-start-tag-with-trailing-solidus standard | This error occurs if the parser encounters a start tag for an element that is not in the list of void elements or is not a part of foreign content (i.e., not an SVG or MathML element) that has a U+002F (/) code point right before the closing U+003E (>) code point. The parser behaves as if the U+002F (/) is not present. |
The codes marked standard are the HTML Standard's own (13.2.2 Parse errors, where the descriptions are non-normative); the standard leaves the tree-construction errors unnamed and parse5, the parser used here, names those itself. Parse errors are syntax only: "Parse errors are only errors with the syntax of HTML." The error handling is defined, so a document with errors still has one exact tree, the one shown above.
6 findings
- noteD5The character encoding declaration
<meta charset="utf-8">No character encoding is declared in the document (no meta charset and no Content-Type meta). If the HTTP response does not declare one either, the browser sniffs the encoding. The HTML Standard requires documents to be UTF-8; <meta charset="utf-8"> in the head says so in the file itself.
- errorD6line 1Images without alternative text
<img>One img element has no alt attribute (line 1). WCAG 2.2 SC 1.1.1 Non-text Content (Level A): "All non-text content that is presented to the user has a text alternative that serves the equivalent purpose". The HTML Standard: "Except where otherwise specified, the alt attribute must be specified and its value must not be empty", and for purely decorative images "the alt attribute must be present but must be empty". Note that an absent alt and an empty alt mean different things.
- warningD13line 1End tags the parser supplied
<div>One div element was closed by the parser, not by an end tag in the source, and div is not among the elements whose end tag the standard allows authors to omit (html, head, body, li, dt, dd, p, rt, rp, optgroup, option, colgroup, caption, thead, tbody, tfoot, tr, td, th). Either the end tag is missing or a later end tag closed this element first (misnesting). The tree shows where the parser ended it.
- warningD15line 1Content moved out of a table
<table>One node was moved before the table: text or elements written inside a table where only table parts (caption, colgroup, thead, tbody, tfoot, tr, td, th) may appear are inserted before the table by the standard's foster parenting rule. In the tree they appear ahead of the table they were written in.
- noteD16Void elements written with a trailing slash
<br />One void element is written with a trailing slash (<br />). The HTML Standard: "On void elements, it does not mark the start tag as self-closing but instead is unnecessary and has no effect of any kind. For such void elements, it should be used only with caution", because "if directly preceded by an unquoted attribute value, it becomes part of the attribute value". Harmless as written here.
- noteD20Elements the parser created
<tbody>The parser created one element that has no tag in the source: tbody. The HTML Standard: "Omitting an element's start tag in the situations described below does not mean the element is not present; it is implied, but it is still there." html, head, body and tbody are the usual ones.
What did not run
- script elements
- 0 (none external)
- inline event handlers
- 0
- javascript: URLs
- 0
- style elements
- 0
- iframes
- 0
This page builds the tree and reads it. Scripts are kept as text, event handler attributes as attributes, URLs as strings; no style is applied, no image, frame or script is fetched. The same parser runs in the hosted API with the same result.
The parser is parse5 8.0.1, which implements the HTML Standard's tokenizer and tree construction as of its release, with the scripting flag off (as DOMParser parses), so noscript content is read as elements. The standard's 2026 processing-instruction tokenization is not in it: <?…> is reported under the earlier name unexpected-question-mark-instead-of-tag-name and becomes a comment, which is also what the current standard does for an xml target. The findings read structure, not meaning: they cannot tell whether an alt text is a good one, whether a heading describes its section, or whether a lang tag is right; headingoffset and headingreset are not applied to the outline. Inputs over 200 000 characters are refused.
Referenser
- HTML Living Standard (WHATWG): 13 The HTML syntax, 13.2.2 Parse errors, 13.2.6 Tree construction
- HTML Living Standard (WHATWG): 3.2.6 Global attributes (id), 4.1.1 html (lang), 4.2 Document metadata (head, title, meta charset), 4.3.11 Headings and outlines, 4.8.4.4 Alternative text for images, 4.10.4 label
- HTML Living Standard (WHATWG): 16.2 Non-conforming features
- Web Content Accessibility Guidelines (WCAG) 2.2, W3C Recommendation 12 December 2024
- parse5 8.0.1, the HTML parser (MIT), with its parse-error codes