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

Metadata and social tags

The invisible head: the title and description a search engine shows, and the tags that decide how a shared link looks.

Part 8 of 13

Intermediate14 min readBack to Courses

The head describes the page

Everything inside <head> is information about the document rather than content of it — nothing there is drawn on the page. Two of those pieces are read by almost everyone who finds you: the <title> and the description.

The title appears in the browser tab, in bookmarks, and as the blue line of a search result. The description is the grey paragraph under it. Neither is written by the search engine: both are yours, which is why a page without them gets a result assembled from whatever words happen to sit near the top.

The title is not the heading

The <title> and the <h1> often say the same words, but they are not interchangeable. The title belongs to the browser tab, the bookmark and the search result; the heading belongs to the page and is read in the flow of the document. A page has one of each, and the title usually carries the site name too.

Titles should be unique across a site. Ten pages all called “Home” give a bookmark list and a set of search results that cannot be told apart. Put the specific thing first and the site name last, so the useful part survives when the tab is narrow.

A head that says what the page is

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Sourdough notes — recipes that worked</title>
  <meta name="description"
        content="Twelve tested sourdough recipes with timings, weights and the failures worth avoiding.">
</head>

What a shared link shows

When someone pastes your page into a chat, a message board or a social feed, the software there builds a little card: an image, a title, a sentence. It does not read your page to do it — it reads four tags that exist for exactly this purpose, the Open Graph tags.

They live in the head as <meta> elements whose property starts with og:. The two you will always write are og:title and og:description; og:image is the one that decides whether the card has a picture at all. twitter:card tells X to show the large version rather than a bare link.

Three readers, one head

Three readers open the same head and each takes a different part. The browser takes the title for the tab and the charset for decoding. A search engine takes the title and description for the result, and may ignore the description in favour of a sentence from the page. A chat app takes the Open Graph tags for its card, and falls back to the title and a guess when they are missing. Writing all three sets is not duplication: it is the same page introduced to three audiences, in the order each one asks for it.

Make the shared link a card

The page has a title and nothing else. Add a description for search results, and the Open Graph tags that turn a shared link into a card with a title, a sentence and an image.

Live Preview
Console output will appear here...

3 left to do

  • The page declares a description
  • The page carries an Open Graph tag
  • The tags carry their content

Description uses name="description"; the Open Graph set uses property="og:…". Every one of them carries its value in content.

The head has an order

<meta charset> should come early — within the first 1024 bytes — because the browser needs to know how to read the file before it reaches the text. The viewport tag is what tells a phone to use the device width rather than a pretend desktop width, and it belongs in the head of every page meant to be read on a phone.

The description and the Open Graph tags are claims about the page, so they belong with the content they describe. meta name="robots" is a request rather than a command: noindex asks search engines to leave the page out, and a page that should not be public is better protected by a login than by a tag.

Write it for a person

A description is a sentence, not a list of words a robot might like. Explain what the page gives the reader, in the same voice as the page itself. Search engines read the page anyway — stuffing the description with repeated keywords does not raise the page, and it makes the result look like spam to the person deciding whether to click.

One description per page, and make it accurate. A description that promises something the page does not deliver is not a ranking trick; it is the reason a visitor leaves.

Three metadata mistakes: the same title and description copied onto every page, which makes the site look like one page repeated; an Open Graph tag with no content, which is ignored; and a description written as a keyword list rather than a sentence. A shared link and a search result are both read by a person — write for that person.

Try these next

  • Write a title that puts the page’s subject first and the site name last.
  • Write a description under 150 characters and check where it ends in a search result.
  • Add og:title, og:description and og:image to a page and preview the card in a share debugger.

A product page worth sharing

The page describes one product and has only a title. Add a description for search results and the Open Graph tags that build a share card: a title, a sentence and an image.

Live Preview
Console output will appear here...

3 left to do

  • The page declares a description
  • The page carries an Open Graph tag
  • The tags carry their content

Use name="description" for search, and property="og:title", og:description and og:image for the card. Each one carries its value in content; a real page needs an absolute image URL, while the relative path here keeps the example offline.

Aim for roughly 150 characters in the description. Longer is cut off with an ellipsis in most search results.

Check what you learned

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

Part 1 of 5

Where does the description meta tag appear?