The Web FrontendDeeper

Kayavak / The Web Frontend / FE·13 HTML / Deeper

Deeper · The Web Frontend

HTML

The questions the chapter doesn't stop for: why this exists, the model to keep in your head, what changes when an assumption does, how sure we are of each claim, and what's still open. Read it after the chapter; back to the chapter.

Why does this exist?

Berners-Lee's first HTML (1991) borrowed from SGML, a document markup standard: tags described what text was (a heading, a list, a link), not how it looked. Then the browser wars of the mid-1990s pushed the other way: Netscape and Microsoft added presentational tags like <font> and <blink>, and pages were laid out with tables. CSS (1996) and the W3C's push for structure tried to separate meaning from presentation again.

The W3C's next plan, XHTML 2, abandoned compatibility with existing pages. In 2004 Apple, Mozilla and Opera formed the WHATWG to evolve HTML instead, specifying the messy reality browsers already handled: forms that validate themselves, <video>, semantic sectioning, and a precise parsing algorithm for every error. That became HTML5 (W3C Recommendation 2014), and since 2019 the W3C and WHATWG agree on one HTML Living Standard maintained by the WHATWG. Semantic HTML matters now mostly because of machines that read pages: assistive technology, search engines and browsers' own features (reader modes, autofill).

The mental model

Try it yourself first: write your own model in the Mental Model Explorer, then compare.

HTML says what each piece of content is. Everything that reads the page (browsers, screen readers, search engines, your own CSS and scripts) builds on that meaning.

Question Answer
What is it? A markup language parsed into the DOM, whose elements carry meaning and default behaviour
Problem it solves Describing documents and forms so that any device or tool can present and use them
Parts Elements and attributes, content models (what may nest where), forms, resource loading
How it works The parser builds a tree; each element maps to an accessibility role and native behaviour (focus, keyboard, submission)
Assumptions The element chosen matches the meaning (a button is a <button>)
When they change A <div> with a click handler looks like a button and isn't one: no keyboard, no role, no form behaviour
Where it fails Complex widgets (comboboxes, tree views) have no native element yet; ARIA fills the gap with care
Related ideas The DOM (ch17), accessibility (ch20), browser parsing (ch18)

What if?

What if every element were a <div>?

Reason it through, then open

The page could look identical with enough CSS and JavaScript, and still be broken for everyone who doesn't use it by mouse and eye. Screen readers would announce no headings, lists or landmarks to jump between; keyboard users couldn't reach the "buttons"; forms wouldn't submit on Enter or validate; search engines would see no structure. You'd have to rebuild with ARIA and scripts what native elements give for free, and most rebuilds miss something.

What if forms needed JavaScript to submit?

Reason it through, then open

Any script error, slow load or blocked script would leave users unable to submit anything. A plain <form> with action and method works with no JavaScript at all; scripts can then improve it. That layering (it works first, then it gets better) is called progressive enhancement.

Where the boundary is

Aspect <a href> <button>
Means Go somewhere Do something
Keyboard Enter Enter and Space
Works without JavaScript Yes: it navigates Only inside a form (submits it)
Gets for free Open in new tab, copy link, history Form submission, disabled state
Mistake A link with href="#" and a click handler that doesn't navigate A button that only changes the URL

How sure are we?

Claim How it's known Where from
WHATWG formed in 2004; one living standard since 2019 Historical WHATWG and W3C announcements
Native elements map to accessibility roles Convention The HTML-AAM specification maps each element to a role
"No ARIA is better than bad ARIA" Measured WebAIM's annual survey of the top million home pages finds more errors on pages that use ARIA
HTML parsing never fails Theorem, of the specification Every input has a defined parse tree, though not always the one the author meant

Still open

Which widgets deserve native elements is ongoing work: customisable <select>, popovers, dialogs and invoker commands have arrived or are arriving, each removing a common source of hand-built, inaccessible components.

What would change your mind? If assistive technology could reliably infer meaning from appearance alone, the argument for semantic markup would weaken to search and maintainability. It can't yet.

Recall

What does semantic HTML give you for free that a styled `<div>` doesn't?

An accessibility role, keyboard behaviour, focus, and native features like form submission.

When should you use `<a href>` and when `<button>`?

A link goes somewhere; a button does something.

What is progressive enhancement?

Build something that works with plain HTML, then improve it with CSS and JavaScript.

Why did the WHATWG form in 2004?

To evolve HTML compatibly with existing pages instead of the W3C's incompatible XHTML 2.

Reflect

Be honest with yourself; this stays in your browser. Anything you can't tick yet is what to revisit.