Vocabulary for this course

The terms the chapters assume, in plain words. You can open this from any chapter.

accessible name
What a browser tells a screen reader an element is called, taken from its text, its label, or an alternative description.
aria-label
An attribute that gives a control an accessible name when no visible text can serve as one.
attribute
A name, sometimes with a value, inside an opening tag that describes the element further, such as where a link goes.
control
An interactive part of a page, such as a text box, checkbox, or button, that a person can operate.
element
One complete piece of a page: an opening tag, its content, and a closing tag, or a single tag when it holds nothing.
empty element
A tag that holds nothing and has no closing partner, such as an image or a line break.
for attribute
An attribute on a label that names the control it describes, so clicking the text operates that control.
form action
The address a submitted form sends its values to, declared in the opening tag of the form.
id attribute
An attribute that gives one element a unique name, which a link or a label can point to.
label
The text attached to a control that says what it is for; clicking it focuses or operates the control it belongs to.
landmark
A page region with a recognised purpose, such as header, nav, or main, that a screen reader can jump to directly.
markup
The tags and attributes that describe the structure of a document, as opposed to its styling or behaviour.
method
The attribute that says whether a form's values travel in the address or in the request body.
name attribute
An attribute that gives a form control a key for its value when the form is submitted.
regular expression
A pattern of characters used to test or match text, such as the shape an email address must have.
request body
The part of a form submission that carries the field values, separate from the address.
reset button
A button that puts every control in a form back to the value it had when the page loaded.
sandbox
An isolated place where a page runs without reaching the rest of the site or the network.
screen reader
Software that speaks a page aloud or shows it in braille, so someone who cannot see the display can still use it.
tag
The name of an element written in angle brackets, such as p or img, which marks where that piece of the page begins or ends.

HTML from the ground up

A complete page, end to end

Everything at once: one small page that has to pass every rule the course has taught, and what to do before you ship it.

Part 13 of 13

Advanced18 min readBack to Courses

Everything, in one page

A page worth linking to is rarely one clever element; it is a handful of ordinary decisions made in order. The document declares its language and its title, the regions are landmarks, the headings descend in order, the image can be read aloud, and the description in the head is the sentence a search result shows.

Nothing in this chapter is new. It is the whole course, applied to one page — which is how the elements stop being a list to remember and become a way of writing.

A plan in words first

Before typing, say what the page is for and who reads it, then name its regions out loud: a header with the site and its navigation, a main column with the content, a footer with the small print. Decide what each block of content is — a heading, a paragraph, a list, an image, a form — and the elements follow from the decisions.

That order is the difference between markup that survives a redesign and markup that has to be rewritten with it.

The page as a set of questions

Every decision on the checklist is really a question about the reader. Who is this page for, and what should they be able to do when it ends? Which part is the page itself, and which part is the same on every page? What is the one heading that names it? What does each image add that the words do not? Answer those four before you type, and the elements stop being a list to memorise: a header is the answer to "what is the same everywhere", a main is the answer to "what is this page for", and an alt is the answer to "what would be lost if this image vanished".

The order of decisions

Content first, structure second, metadata last. Decide what the page says before choosing elements, then decide which region each block belongs to, then write the title and description that summarise what you built. In that order, the metadata is a description rather than a guess.

The reverse order produces a page that looks finished and reads badly: a layout chosen first, content poured into boxes, and heading levels picked because they fit. The browser will render it, and a screen reader will still have nothing to navigate.

The checklist this page must pass

  • The document declares a language, so screen readers pronounce it correctly.
  • The head carries a title and a description, so the tab and the search result are right.
  • One h1, and headings that descend without skipping a level.
  • Landmarks: header, nav, main and footer rather than divs with classes.
  • Every image either says something with its alt, or is marked decorative with alt="".
  • Every link has a real destination, and every form control has a label.
  • The finished page validates, and passes the keyboard and zoom test from the accessibility chapter.

The page, made whole

This page is built from divs, speaks no language, and its photograph cannot be described. Make it a page that passes the checklist: a language on the document, a description in the head, real landmarks, and an image with alt text.

Live Preview
Console output will appear here...

7 left to do

  • The document declares a language
  • The head carries a description
  • The top region is a header
  • The links sit inside a nav element
  • The content is inside a main element
  • The closing line is a footer element
  • The photograph has alt text

<html lang="en">, a <meta name="description" …> beside the charset, and header / nav / main / footer in place of the divs and the closing paragraph.

Before you ship it

Run the page through a validator — the W3C keeps one at validator.w3.org — and fix what it names; a stray unclosed tag is the beginning of a layout that breaks in one browser. Then walk it with the keyboard, zoom to 200%, and read it aloud, in order. Those three passes find most of what a reader would stumble on. Do them in that order, and do them twice: the second pass is where a page that only looked finished turns into one that holds up. A page that passes the validator and the keyboard is not perfect, but every remaining problem is now a judgement call rather than an accident.

Finally, let it be simple. A small page that does five things properly beats a large one that does twenty approximately, and the next person to open the file will agree.

What a validator can and cannot tell you

A validator checks the grammar: unclosed tags, attributes that do not belong, elements in places they cannot go. It cannot tell you whether a heading says the right thing, whether the alt text is useful, or whether the form asks a question a person can answer. Those are judgement calls.

Use it in two passes. First the validator, until it is quiet; then the keyboard, the zoom and the read-aloud test. A page can be perfectly valid and still unusable — validity is the floor, not the finish line.

Three mistakes that survive a validator: aria-label on a plain <div>, which has no role to name; an alt that repeats the caption word for word; and a form where every field is labelled only by a placeholder. None is a syntax error, and each makes the page harder to use.

Try these next

  • Take a page you already have and write its regions in a sentence before changing any markup.
  • Run it through the validator, fix only the errors, then do the keyboard pass.
  • Remove the alt from one meaningful image and see what a screen reader says instead.

A workshop page, checked

This workshop page fails the checklist in four places. Give the document a language, turn the table into a captioned table with a real header row, give both fields visible labels, and describe the photograph. Leave the rest of the content alone.

Live Preview
Console output will appear here...

6 left to do

  • The document declares a language
  • The table has a caption
  • The header row is wrapped in a thead
  • There are at least two header cells
  • A label is connected to a field
  • The photograph has alt text

<html lang="en">; a <caption> and <thead> around the first row, with <th scope="col">; a <label for="…"> for each input; and an alt on the image.

Keep this checklist next to any page you build. Every item on it is a rule from this course, and each one is cheaper to follow while writing than to repair afterwards.

Check what you learned

One question at a time. A wrong answer explains itself — take another go.

Part 1 of 5

How many h1 elements should a page usually have?