Online admissions open for the SEO, web development and networking & cybersecurity courses. Enquire for the next batch.

HTML Semantic Elements: Structure, Landmarks and Headings

6 min read Updated By the SkillNewton team

What are HTML semantic elements?

HTML semantic elements are tags whose names describe the meaning of their content, such as <header>, <nav>, <main>, <article> and <footer>. Unlike a generic <div>, they tell browsers, screen readers and search engines what each part of a page is, which improves accessibility and makes code easier to maintain.

Semantic versus non-semantic markup

A <div> or <span> says nothing about its content; it is just a box for styling or scripting. A semantic element carries meaning. Both can look identical on screen, but assistive technology, browser reader modes and search engines read the meaning, not the styling.

<!-- Non-semantic -->
<div class="header"><div class="nav">...</div></div>
<div class="content"><div class="post">...</div></div>

<!-- Semantic -->
<header><nav aria-label="Main">...</nav></header>
<main><article>...</article></main>

The benefits are practical:

  • Accessibility: screen readers announce elements such as navigation and main content, and let users jump between them.
  • Built-in behaviour: a <button> is focusable and responds to Enter and Space; a <details> element opens and closes with no script.
  • Reader modes and search engines: clear structure helps tools pick out the main article from menus, adverts and footers.
  • Maintainability: <nav> and <aside> are easier to scan in a template than a stack of nested <div class="..."> wrappers.

Semantic markup is not about avoiding <div> altogether. Use a <div> when you need a wrapper purely for layout, and a semantic element whenever the content has a recognisable role.

The main structural elements

ElementUse it forLandmark role
<header>Introductory content: logo, site title, page headingbanner, when not inside article, aside, main, nav or section
<nav>Major blocks of navigation linksnavigation
<main>The unique, central content of the page; one visible per pagemain
<article>Self-contained content that makes sense on its own: a post, product card, commentnone by default
<section>A thematic group of content, normally with a headingregion, only when it has an accessible name
<aside>Content tangential to the main content: related links, a sidebarcomplementary
<footer>Closing information: copyright, contact, related linkscontentinfo, when not nested in sectioning content

article or section?

Ask whether the content could be lifted out and published elsewhere, for example in a feed, and still make sense. If yes, it is an <article>. If it is one part of a larger whole, such as the "Syllabus" part of a course page, it is a <section>. If it has no heading and no real theme, it is probably just a <div>.

Smaller semantic elements

  • <figure> and <figcaption> pair an image, chart or code sample with its caption.
  • <time datetime="2026-11-10"> gives dates a machine-readable value.
  • <address> holds contact details for the page or article author.
  • <search> wraps a site search form and creates a search landmark in current browsers.

How landmarks help screen reader and keyboard users

Browsers expose certain elements to assistive technology as landmarks. Screen reader users can list the landmarks on a page and jump straight to the main content or navigation, much as sighted visitors scan the layout. Good landmarks save them from listening to the whole header on every page.

  • Use exactly one visible <main> per page.
  • When a page has more than one <nav>, give each a distinct name, such as aria-label="Main" and aria-label="Footer".
  • Make sure all visible content sits inside some landmark, so nothing is skipped when users jump between them.
  • Prefer native elements to ARIA roles; <nav> is better than <div role="navigation"> because it needs no extra attributes.

Building a clear heading outline

Headings <h1> to <h6> form the page's table of contents. Screen reader users frequently navigate by heading, and search engines use headings to understand topics. The levels should describe nesting: an <h3> is a subtopic of the <h2> above it.

Older tutorials describe an "outline algorithm" in which sectioning elements reset heading levels so every section could start with an <h1>. Browsers and screen readers never implemented it, and it was removed from the HTML standard in 2022. Only the heading level numbers count, so choose them deliberately.

h1  Learn PHP Online
  h2  What you will build
    h3  A contact form
    h3  A login system
  h2  Syllabus
  h2  Frequently asked questions
  • Use one <h1> describing the page's main topic.
  • Do not skip levels on the way down, for example from <h2> straight to <h4>.
  • Choose the level for structure and set the size with CSS; never pick a heading tag because it looks the right size.

Site-wide parts such as the footer or a sidebar often have their own headings, for example "Related posts" or "Contact us". Give them levels that fit the outline, usually <h2>, rather than styling a plain paragraph to look like a heading, so screen reader users can still find them by heading navigation.

Marking up a page step by step

<body>
  <a class="skip" href="#content">Skip to main content</a>
  <header>
    <a href="/">SiteName</a>
    <nav aria-label="Main">
      <ul><li><a href="/courses/">Courses</a></li><li><a href="/blog/">Blog</a></li></ul>
    </nav>
  </header>

  <main id="content">
    <article>
      <h1>How to Plan a Portfolio Website</h1>
      <p>Published <time datetime="2026-11-10">10 November 2026</time></p>
      <section>
        <h2>Choose your pages</h2>
        <p>...</p>
      </section>
      <figure>
        <img src="sitemap.png" alt="Sitemap with home, projects and contact pages">
        <figcaption>A simple three-page portfolio structure</figcaption>
      </figure>
    </article>
    <aside aria-label="Related posts">...</aside>
  </main>

  <footer>
    <nav aria-label="Footer">...</nav>
    <p>&copy; 2026 SiteName</p>
  </footer>
</body>
  1. Identify the repeated site-wide parts: header, main navigation and footer.
  2. Wrap the unique content of the page in a single <main>.
  3. Mark self-contained pieces as <article> and thematic parts with headings as <section>.
  4. Move side content into <aside> and give extra navigation blocks a label.
  5. Write the heading outline and check that the levels nest correctly.
  6. Use <div> only where you need a wrapper for grid or flexbox styling.

Practical exercise: refactor a div-only page

Find a page you built earlier, or write one with a header, menu, three blog post previews, a sidebar and a footer using only <div> elements, as in the HTML basics guide.

  1. Replace each wrapper with the matching semantic element.
  2. Make each blog preview an <article> with its own heading and a <time> element.
  3. Add a skip link and label both navigation blocks.
  4. Open the accessibility tree in your browser dev tools and confirm the banner, navigation, main, complementary and contentinfo landmarks appear.
  5. Use a browser extension or the dev tools to list headings and fix any skipped levels.

You are done when the page looks the same as before, every piece of content sits inside a landmark, and the heading list reads like a sensible table of contents. Writing clean templates like this is practised in SkillNewton's PHP foundation course.

Common mistakes

  • Using several visible <main> elements, or none at all.
  • Choosing heading levels for their default size, which produces a confusing outline.
  • Wrapping every block in <section> without a heading, which adds no meaning.
  • Leaving multiple <nav> elements unlabelled, so screen reader users hear "navigation" twice with no way to tell them apart.
  • Adding ARIA roles such as role="main" to elements that already have that role natively.

Frequently asked questions

Do semantic elements help SEO?

They help search engines understand which part of a page is the main content and how topics are organised, and a clear heading structure supports this. They are not a ranking shortcut on their own; the content still has to answer the searcher's question.

Can I use more than one header or footer on a page?

Yes. Each <article> or <section> can have its own <header> and <footer>. Only the top-level ones, outside sectioning content, become the banner and contentinfo landmarks.

Is it wrong to use div elements?

No. <div> is the right choice for wrappers that exist only for layout or styling. The problem is using it where a semantic element or a <button> would describe the content better.

Want to Learn This Properly?

The PHP Web Development: Foundation & Practical Implementation (Online) turns guides like this into practised skills, with projects on real websites.

WhatsApp Call Us Now

Free counselling

Send an Enquiry

Tell us which course you are interested in. We reply by email or phone with the next batch and how to enrol.

Protected by reCAPTCHA. Google Privacy and Terms apply.

We reply by email or phone within working hours. No spam.