Introduction
HTML is the language of web pages. Tim Berners-Lee created it at CERN around 1990, together with the first web browser and server. An HTML file is text marked up with tags that say what each part is, such as a heading, paragraph, link, image or table, and browsers turn it into the page you see, styled by CSS and made interactive by JavaScript. Saved web pages, email newsletters and help files are often HTML too.
HTML is maintained by WHATWG as a “living standard” that is updated continuously,
rather than in numbered versions. Files use .html, or .htm
from the days of three-letter extensions.
Structure
An HTML document starts with <!DOCTYPE html>, then an
html element holding a head, with the title, character
encoding and links to stylesheets and scripts, and a body with the
content. Elements are written as a start tag, content and an end tag, such as
<p>Hello</p>, and start tags carry attributes such as
href on a link. Some elements are void and have no end tag, and many end
tags can be left out. Characters that have a meaning in markup are written as character
references, such as & for an ampersand. Every browser reads every
file, however badly formed, by one algorithm the standard defines exactly.
The other pages cover the syntax, every element and attribute, all the named character references, the parsing algorithm and its parse errors, how the encoding is found, and the versions and document types.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>A small page</title>
</head>
<body>
<h1>Hello</h1>
<p>Read the <a href="https://html.spec.whatwg.org/">HTML standard</a>.</p>
</body>
</html>
Not described
The pages follow the HTML Standard. The explorer reads HTML as a tree of its own, with the parsing errors the standard names.
Known, not yet covered
- Viewer: the page is not rendered; it needs a new viewer component.
- Viewer: the Text tab is shown in windows of 1 MiB (First, Previous, Next, Last, Go to line), so every byte of a big file is reachable.
- Viewer: a file over 48 MiB (or a decoded entry over 8 MiB) is read by the tokenizer in windows
(every state and named parse error, every input-stream error) and shown as its tokens, in groups of 1,000,
with the Overview facts and every problem in pages. The tree builder is not run on it: there is no DOM tab, no
implied
<html>,<head>or<body>, and the tree errors (misplaced tags, end tags with nothing open) are not found; the content state after<script>,<style>,<title>,<textarea>and the other raw-text elements is set as the builder sets it, but SVG and MathML integration points are not modelled and the nesting depth is approximate. - Viewer: fragment parsing and the placement of declarative shadow DOM are not modelled.
Links
Software
- Google Chrome – Google’s web browser (Windows, macOS, Linux, mobile)
- Firefox – Mozilla’s web browser (Windows, macOS, Linux, mobile)
- Safari – Apple’s web browser (macOS, iOS)
- Microsoft Edge – Microsoft’s web browser (Windows, macOS, Linux, mobile)
- Visual Studio Code – free code editor for writing HTML (Windows, macOS, Linux)
- Pandoc – command-line converter between HTML and many other formats (Windows, macOS, Linux)
Developers
- parse5 – HTML parser that follows the standard (JavaScript)
- html5lib – HTML parser that follows the standard (Python)
- Beautiful Soup – library for reading and searching HTML (Python)
- jsoup – HTML parser (Java)
Reference
- HTML Living Standard – WHATWG’s definition of HTML
- Encoding Standard – WHATWG’s definition of the encoding labels and decoders browsers use
- HTML – MDN Web Docs’ reference and guides