# Structure Elements: header, nav, main, section and footer

Structure elements such as header, nav, main, aside and footer label the parts of a page by what they are, which helps people using screen readers, search engines, and you when you style each part.

Novice · HTML · CSS · Updated November 15, 2026

By Gregor Dzierzon

## After this lesson you can

- Mark up a page's parts with header, nav, main, section, article and footer
- Choose between a meaning element and a div or span, and explain who the meaning helps
- Mark up a sidebar with aside, and a picture and its caption with figure and figcaption

## Key takeaways

- `<header>`, `<nav>`, `<main>` and `<footer>` label a page's big parts: the top, the menu, the main content and the bottom.
- `<section>` groups content on one theme under a heading. `<article>` holds something that makes sense on its own, such as a pet's card.
- `<aside>` holds something related to the page but beside its main content, such as a sidebar. `<figure>` holds a picture with its caption, `<figcaption>`.
- `<div>` and `<span>` are boxes with no meaning: `<div>` for a block, `<span>` for words inside a line. Use them when no other element fits.
- Choosing elements for their meaning is called semantic HTML. It lets screen readers jump between parts, and lets CSS style each part by name.

Look at almost any website and you'll find the same parts: a bar across the top with the name or logo, a menu of links, the main content, and a strip at the bottom with an address or a copyright line. Styling a page mostly means styling those parts: "make the top bar dark blue", "put the menu links in a row", "make the footer text gray". HTML has an element for each one, and once your page uses them, CSS can find every part by name.

## Labeling the rooms

On moving day, a box labeled *kitchen* goes straight to the kitchen. A box labeled *stuff* gets left in the hall while someone opens it to find out. HTML has labels for the "rooms" of a page:

```html
<body>
  <header>
    <p>Paws & Whiskers</p>
    <nav>
      <a href="index.html">Home</a>
      <a href="pets.html">All pets</a>
      <a href="adopt.html">How to adopt</a>
    </nav>
  </header>
  <main>
    <h1>Meet Biscuit</h1>
  </main>
  <footer>
    <p>Paws & Whiskers, 412 Willow Lane. Open Tuesday to Sunday.</p>
  </footer>
</body>
```

- **`<header>`**: the top of the page, with the site's name or logo. It often holds the menu too.
- **`<nav>`**, short for *navigation*: the menu of links to other pages.
- **`<main>`**: the content that is this page's own, the part that's different on every page. A page has one.
- **`<footer>`**: the bottom of the page, with contact details, a copyright line, or links to the small print.

These big parts are called **landmarks**: the places a visitor can find their way by.

## section and article

Inside `<main>`, two more elements group the content:

```html
<main>
  <h1>Meet Biscuit</h1>
  <section>
    <h2>Biscuit's story</h2>
    <p>Biscuit came to us when his family moved to an apartment that doesn't allow dogs.</p>
  </section>
  <article>
    <h3>Pepper</h3>
    <p>A two-year-old cat who sleeps in sunbeams.</p>
  </article>
</main>
```

- **`<section>`** groups content on one theme, and it starts with a heading: *Biscuit's story*, *Fast facts*, *Other pets you might like*.
- **`<article>`** holds something that makes sense on its own, so it could be moved to another page and still be complete: a pet's card, a blog post, a review. Pepper's card could appear on the home page or on a "cats" page unchanged.

When you aren't sure which to use, ask: "would this make sense on its own, somewhere else?" If yes, it's an `<article>`. If it only makes sense as part of this page, it's a `<section>`.

## aside, figure and figcaption

Two more parts turn up on almost every site: a box beside the main content (the shelter's visiting hours, a list of other pets to meet), and a photo with a line of text under it. Here's the "Meet Biscuit" page with one of each:

```html
<main>
  <h1>Meet Biscuit</h1>
  <figure>
    <img src="images/biscuit.jpg" alt="Biscuit the beagle sitting in the grass, ears up">
    <figcaption>Biscuit on his first day at the shelter.</figcaption>
  </figure>
  <section>
    <h2>Biscuit's story</h2>
    <p>Biscuit came to us when his family moved to an apartment that doesn't allow dogs.</p>
  </section>
  <aside>
    <h2>Visiting day</h2>
    <p>Meet our pets every Saturday from 10 to 2. No appointment needed.</p>
  </aside>
</main>
```

- **`<aside>`**, read "aside", holds something related to the page but beside its main story, like a note in the margin of a book: a sidebar, a "Visiting day" box, links to other pets you might like. Take it away and the page still tells Biscuit's whole story. A screen reader can jump to it, as it can to the other landmarks.
- **`<figure>`** holds a picture that belongs with the text around it, such as Biscuit's photo, and **`<figcaption>`**, short for *figure caption*, is its caption: the line of text shown with it. The caption goes inside the `<figure>`, first or last.

The `<img>` still needs its `alt` text. The alt text describes the picture for people who can't see it; the caption is shown to everyone and says something more about it, such as when it was taken. When you aren't sure about an `<aside>`, ask: "is this about the page, but not part of its main story?" If yes, it's an `<aside>`.

## div and span: boxes labeled "stuff"

Sometimes you need a box only so CSS can style it: a frame around a photo that has no caption, or a price in a different color. No meaningful element fits, and that's what `<div>` and `<span>` are for. They carry no meaning at all:

```html
<div>
  <img src="images/biscuit.jpg" alt="Biscuit the beagle sitting in the grass, ears up">
</div>
<p>Adoption fee: <span>$150</span>, which covers his shots and a microchip.</p>
```

- **`<div>`** (short for *division*) is a box that starts on its own line, like a paragraph does. It can hold anything.
- **`<span>`** wraps a few words inside a line of text, without breaking the line.

On their own, they don't change how anything looks. In the next lesson, *Hooks for CSS: the class and id Attributes*, you give them names that CSS can find. Reach for a meaningful element first, and use `<div>` or `<span>` when none fits.

## Who the meaning helps

Choosing elements for what their content *is* is called **semantic HTML** (*semantic* means "to do with meaning"; your class may call these elements *semantic elements* or *sectioning elements*). It helps three kinds of reader:

- **People using screen readers.** A screen reader can list a page's landmarks and jump straight to `<main>`, skipping the menu they've already heard on every page. A page built from `<div>`s gives them nothing to jump to.
- **Search engines**, which read `<main>` and `<article>` to work out what the page is about.
- **You, writing CSS.** Every part already has a name to aim at, with no extra labels:

```css
header {
  background-color: darkslateblue;
}

footer {
  color: dimgray;
}
```

![The Meet Biscuit page drawn as an outline: a header across the top holding the site name and the nav links, the main area below it with Biscuit's heading, story section and two pet card articles, and a footer across the bottom](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/10/fa730da2b7f747868656a9414a68713e.webp)

**Try it.** Wrap the content of your `meet-biscuit.html` in a `<header>`, a `<main>` and a `<footer>`, as in the first example, and add a `header` rule to `styles.css`. Save, and the whole top of the page changes color at once.

## Do it: give the Biscuit page its landmarks

A volunteer built the "Meet Biscuit" page out of `<div>` boxes. It looks fine, but a screen reader finds nothing to jump to, and the designer can't write a rule for "the footer" because there isn't one. Swap each box for the element that says what it is:

- The site's name and the menu of links make the top of the page, and the links are marked as the menu.
- Biscuit's own content is the page's main part, and the address is at the bottom.
- Biscuit's photo and its caption stay together, as a picture with its caption.
- *Biscuit's story* is a section of the page, and the *Visiting day* box sits beside the main story.

Edit the page in the box. When you're done, no `<div>` is left: every box has an element that means something.

Practiced live on the lesson page: write the HTML right there and check it.

## Check yourself

2 questions to try on the lesson page.

## So what

A page whose parts are labeled by meaning is easier for everyone to use, and easier to style: when CSS can say `header`, `nav` and `footer`, half your work of pointing at things is already done.

## Key terms

- [Semantic HTML](https://www.ask-codey.com/glossary/semantic-html)
- [Landmark](https://www.ask-codey.com/glossary/landmark)
- [&lt;aside>](https://www.ask-codey.com/glossary/aside)
- [&lt;figure>](https://www.ask-codey.com/glossary/figure)
- [&lt;div>](https://www.ask-codey.com/glossary/div)
- [&lt;span>](https://www.ask-codey.com/glossary/span)

## Cheat sheets

- [Structure Elements: header, nav, main, section and footer](https://www.ask-codey.com/cheat-sheets/css-html-structure-elements-cheat-sheet)

## Related

- [The Page Skeleton, and Three Places CSS Can Go](https://www.ask-codey.com/lessons/css-html-page-skeleton)
- [Hooks for CSS: the class and id Attributes](https://www.ask-codey.com/lessons/css-html-class-and-id)

Source: https://www.ask-codey.com/lessons/css-html-structure-elements
