Book a free demo

Web Developer Path ยท lesson 5 of 18

Semantic page layout

Structure a page with meaningful elements instead of anonymous boxes, so people, screen readers and search engines understand it.

What you will learn

  • what semantic means and why it helps accessibility and search engines
  • <header>, <nav>, <main>, <section>, <article>, <aside>, <footer>
  • using one <h1> and headings in order

Understand the idea

A semantic element describes what its content is, not just how it looks. A plain <div> says nothing, but <nav> says "these are the main links" and <footer> says "this is the end matter". Semantic tags give a page landmarks. Screen reader users can jump straight to the main content or the navigation, and search engines understand which part of a page is the real content.

The usual page layout has these parts. <header> holds the page title or logo. <nav> holds the main navigation links. <main> holds the unique content of the page and should appear only once. Inside it, <section> groups related content under a heading, <article> is a self-contained piece such as a blog post or a news story that would make sense on its own, and <aside> holds side content such as related links. <footer> closes the page with copyright or contact details.

Headings follow the same order. Use one <h1> for the page title, <h2> for the sections, <h3> for parts of a section. Do not pick a heading because of its size, because CSS controls size. Pick it for its level in the outline.

Example

A semantic page
<body>
  <header>
    <h1>Maths Club</h1>
    <nav>
      <a href="#news">News</a>
      <a href="#events">Events</a>
    </nav>
  </header>
  <main>
    <section>
      <h2>News</h2>
      <article>
        <h3>We won the quiz</h3>
        <p>Well done to everyone.</p>
      </article>
    </section>
    <aside>Next meeting: Friday</aside>
  </main>
  <footer>ยฉ Maths Club</footer>
</body>

Each element has one clear job. Swap them all for div and the page would look the same to your eyes but make no sense to a screen reader.

Your turn: code to type and practise

Build the layout: a header with an h1 and a nav holding two links, a main with a section that contains an article, an aside, and a footer with some text.

Stretch challenge

Add a second article and an h2 that introduces the section.

โ† Images, audio, video and embedsForms and user input โ†’

HTML

More in this module

Keep going in Web Developer Path

Practise the idea

๐Ÿ›ก๏ธ Play Knights and Knaves

Knights always tell the truth and knaves always lie. Read their words and work out who is who.

Play now

FAQ

Semantic page layout: common questions

What does semantic HTML mean?

Using elements whose names describe their purpose, such as nav, main and footer, instead of generic div boxes.

How many main elements can a page have?

One. The main element holds the unique content of the page.

Does semantic HTML help SEO?

It helps search engines understand the structure of your page, which supports good indexing, but it works together with good content and clear headings.

I am stuck. What can I do?

Press Hint for a nudge, read the message next to each goal, and compare your code with the lesson text. If you still need it, Show answer reveals a model solution. Try to type it yourself rather than copy it.

Does my work get saved?

Your ticks and XP are saved in this browser, and in your account if you log in. The code you type is not stored on a server.

Start a conversation

Enjoying coding? Meet a teacher.

Tell us the learner's age, country and what they would like to build, and we will suggest a class. A parent or guardian can make the enquiry.

  • Tell us the learnerโ€™s age or grade and goals
  • Weโ€™ll suggest a suitable class or learning path
  • Weโ€™ll confirm format, timing and fees with a parent or guardian

For a childโ€™s class, please have a parent or guardian send the enquiry. Avoid sharing passwords or sensitive personal details.

Weโ€™ll use your details only to respond to this request.

Play it, don't just read it

Write some code right now

Free games that need no sign-up. Pick one and play for five minutes.

All free games โ†’
Chat on WhatsApp
Esc

Try