Sub topic 12
Semantic Layout Elements
This chapter assumes you can write a complete HTML document, nest elements validly, and use headings and paragraphs. Here you will replace generic containers with elements that describe the role of each part of a page.
Why semantics matter
A semantic element names its purpose. A <div> says nothing about its content, but a <nav> says "this is a group of navigation links." Browsers, search engines and assistive technology such as screen readers use these names. A screen reader user can jump straight to the main content or the navigation list, but only if the page marks them.
Semantic elements do not change how the page looks by default. Styling comes later with CSS. They add meaning.
The main elements
| Element | Purpose |
|---|---|
| `header` | Introductory content for the page or for a section, such as a title or logo |
| `nav` | A block of major navigation links |
| `main` | The central content of the page. Use only one visible `main` per page |
| `section` | A themed group of content, normally with its own heading |
| `article` | A self-contained piece that makes sense on its own, such as a post or news story |
| `aside` | Content related to the surrounding content but separate from it, such as a tip or sidebar |
| `footer` | Closing content for the page or section, such as copyright or contact details |
A worked example
<body>
<header>
<h1>Garden Notes</h1>
<nav>
<a href="/">Home</a>
<a href="/articles">Articles</a>
</nav>
</header>
<main>
<article>
<h2>Growing tomatoes</h2>
<p>Tomatoes need sun and regular watering.</p>
</article>
<aside>
<p>Tip: water in the morning.</p>
</aside>
</main>
<footer>
<p>© 2026 Garden Notes</p>
</footer>
</body>The header holds the site title and the nav. The main holds the unique content of this page: one article and an aside with a related tip. The footer closes the page. The © is a character reference that prints the copyright sign.
The page structure looks like this:
Choosing between section, article and div
Pick the element by asking what the content is.
- Could the content be lifted out and published alone, such as in a feed? Use
article. - Is it a themed part of a larger page that deserves a heading? Use
section. - Is it only a wrapper, for example to apply styling? Use
div.
A section without a heading is usually a sign that div is the better choice.
Common errors
- Using more than one visible
main. A page has one main content area. Puttingmaininsidearticle,aside,header,footerornavis also invalid. - Wrapping every link group in
nav. Reserve it for major navigation. A short list of links in a footer does not need it. - Choosing an element for its looks. Do not use
asideto get an indented box orheaderto get large text. Pick the element for its meaning and style it with CSS. - Skipping heading levels. Each
articleorsectionshould continue the logical order. In the example,h1is the site title andh2is the article title. - Replacing everything with
div. A page made only of divs works visually but gives assistive technology nothing to navigate by.
Check your understanding
Exercise
A page has a site logo with links to Home and Contact at the top, a blog post as its unique content, a "Related reading" box beside the post, and a copyright line at the bottom. Which semantic elements would you use for each part?
Show answer
Wrap the logo and links in header, with the links in a nav. Put the blog post in an article inside main. Put the "Related reading" box in an aside, also inside main. Put the copyright line in a footer.
Exercise
A developer wraps a styled yellow notice box in <section> without a heading, just to get a container. Which element is a better choice, and why?
Show answer
Use div. A section is a themed group of content that normally has a heading. A div is the right choice when the element is only a styling wrapper with no meaning of its own.