Basic

The elements you actually reach for

Most pages are built from a short list of elements: paragraphs, headings, lists, links, images, and a few containers. Learning that short list covers most writing, and the rest is looked up rather than memorised.

What you will see

Bread becomes a link. The href is what makes it one; without it the anchor is plain text.

About 1 min of reading

Try It

Mark up a short passage.

1

Write it

Shopping list

Things to buy this week.

  • Bread
  • Oil

Before you run it, say out loud what it will print. Then open the answer.

What it prints
A heading, a paragraph, and a bulleted list of two items.
2

Add a link

Before you run it, say out loud what it will print. Then open the answer.

What it prints
Bread becomes a link. The href is what makes it one; without it the anchor is plain text.

Put it in order

Before you write anything, put these lines back in the right order. Click a line to move it up one step. This support step is easier than writing code from scratch, and it is here to make the last example stick.

Data Flow

Content maps onto a small set of elements.
1 Read the content
↓
2 Ask what each piece is
↓
3 Choose the element that means it
↓
4 Style the result
Why this works
Headings in order

A page that jumps from h1 to h4 has a gap a reader can feel and a tool can detect. The level states the depth in the document, so choose the level by where the heading sits, not by how large you want it.

Lists for real lists

A list of items belongs in ul even when the design wants them side by side. CSS can lay a list out in any direction; the element is what tells a reader there are several things.

Examples

Text elements

p for a paragraph, h1 to h6 for headings in order, ul for a list where order does not matter, ol when it does. Those four cover almost all prose on a page.

a and img

An anchor with an href is a link; an img with a src and an alt is an image. Both need their second attribute to be correct: a link without href is not a link, and an image without alt is invisible to a reader who cannot see it.

Containers sparingly

div groups things for styling; section groups things that are a section of the document. Reaching for a div when a real element exists loses the meaning, so use the fewest containers that carry the structure.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← The two languages on a page
Previous Lesson
The two languages on a page
Next Lesson
Selecting what to style
Selecting what to style →