Semantic HTML & SEO

Tags that describe what something is, not just how it looks.

Two ways to build the same page — one using meaningful tags, one using only <div>. Below that, the HTML tags that matter most for search engines, with examples.

Semantic vs. non-semantic markup

Both versions render identically in a browser. The difference is invisible to the eye and obvious to a search engine, a screen reader, or another developer reading the code.

Non-semantic — divs only

1<div class="top">
2 <div class="logo">My Site</div>
3 <div class="links">
4 <div>Home</div>
5 <div>About</div>
6 </div>
7</div>
8
9<div class="post">
10 <div class="title">Trail notes</div>
11 <div>Posted on the trail</div>
12 <div>It rained the whole way.</div>
13</div>
14
15<div class="bottom">© 2026</div>
What's wrong here
  • Search engines can't tell the navigation from the footer — every block is just a generic div.
  • A screen reader can't jump to "main content" or "navigation" because there's nothing to identify them.
  • The "title" is styled with a class, not marked as a heading, so it carries no structural weight.

Semantic — meaningful tags

1<header>
2 <h1>My Site</h1>
3 <nav>
4 <a href="/">Home</a>
5 <a href="/about">About</a>
6 </nav>
7</header>
8
9<main>
10 <article>
11 <h2>Trail notes</h2>
12 <time datetime="2026-06-30">Posted on the trail</time>
13 <p>It rained the whole way.</p>
14 </article>
15</main>
16
17<footer>© 2026</footer>
Why this is better
  • <nav>, <main>, and <footer> tell every tool — browser, search engine, screen reader — exactly what each region is for.
  • <article> and <h2> mark the post as a standalone, headed piece of content search engines can index on its own.
  • <time datetime="..."> gives machines an unambiguous date, separate from the human-readable text.

What SEO actually means

Search engine optimisation is the practice of structuring a page so that search engines can understand what it's about, and rank it for the right queries. Most of it comes down to two things: writing clear, well-organised HTML, and giving the page accurate metadata. No amount of styling fixes a page a search engine can't parse.

!
Generic divs hide your content's structure

A search engine crawling the non-semantic example above sees a flat pile of text. It has no signal for what's the headline, what's the navigation, or what's the actual article — so it can't confidently rank the page for anything specific.

Semantic tags hand the crawler a map

With <h1>, <article>, and <nav> in place, the crawler can identify the page title, the primary content, and the site structure — the same signals it uses to decide what the page is about and how trustworthy it is.

The tags that matter most

These live in <head> and at the top of <body>. Each one answers a different question a search engine or social platform asks about the page.

<title>

Page title

The single biggest on-page ranking factor. It's also what shows as the clickable blue link in search results — keep it under about 60 characters.

1<title>Trail Notes — Backcountry Hiking Blog</title>
meta description

Search snippet

The grey summary text under the title in search results. Doesn't directly affect ranking, but a good one improves click-through rate.

1<meta name="description"
2 content="Field notes from rainy trails.">
<h1>

One per page

Tells both readers and crawlers the single main topic. Use exactly one per page, then step down through <h2> and <h3> for subsections — never skip levels.

1<h1>Backcountry Hiking Blog</h1>
alt

Image alt text

Describes an image for crawlers and for anyone using a screen reader. Images without it are essentially invisible to both.

1<img src="trail.jpg"
2 alt="Muddy trail through a pine forest">
canonical

Preferred URL

Tells search engines which version of a page is the "real" one when the same content is reachable at more than one URL, preventing duplicate-content penalties.

1<link rel="canonical"
2 href="https://example.com/trail-notes">
og:*

Open Graph tags

Control how a link looks when shared on social media — the preview title, description, and image. Not used for ranking, but essential for click-through off-platform.

1<meta property="og:title" content="Trail Notes">
2<meta property="og:image" content="/trail.jpg">

If you only do five things

A rough priority order for a student putting together their first page.

01
Write one accurate <title>Specific to the page, not the whole site — "Trail Notes — Backcountry Hiking Blog", not just "Home".
02
Use one <h1>, then nest headings properlyDon't pick heading levels for their font size — pick them for the outline they create.
03
Reach for <nav>, <main>, <article>, <footer> before <div>If a tag already describes the region, use it — div is the fallback, not the default.
04
Give every <img> real alt textDescribe what's in the image, not "image of" or the filename.
05
Add a meta descriptionOne or two honest sentences about the page — it's free advertising in the search results.