beginner20 min

Semantic HTML: Links, Images, Lists & Tables

Move beyond generic divs — structure pages with semantic landmarks, and add links, images, lists, and tables correctly.

What you'll learn

  • Choose semantic landmark elements (header, nav, main, section, article, aside, footer) over generic divs where appropriate
  • Create links with <a href> and images with <img src alt>
  • Structure content with ordered/unordered lists and tables

Prerequisites

Explanation

You could build an entire website using only <div> elements, and the browser would happily render it. But a page made only of divs tells a screen reader, a search engine, and the next developer who opens the file absolutely nothing about what each part is for. Semantic HTML fixes that by choosing elements whose names describe their role.

Landmark Elements

A handful of elements describe the major regions of a page:

  • <header> — introductory content for a page or a section, often a logo and heading.
  • <nav> — a block of primarily navigational links.
  • <main> — the one region holding the page's unique, central content (only one per page).
  • <section> — a thematic grouping of content, usually with its own heading.
  • <article> — a self-contained piece of content that would still make sense if pulled out and syndicated elsewhere, like a blog post or product card.
  • <aside> — content tangentially related to the main content, like a sidebar.
  • <footer> — closing content for a page or section, like copyright or contact links.

These aren't just cosmetic labels. Screen readers expose them as "landmarks" that let a visitor jump straight to navigation or straight to the main content, instead of listening through everything from the top every single time. Use a plain <div> only when none of these more descriptive elements fit.

Links and Images

A link is written <a href="destination">visible text</a>. The href attribute is what makes it a link at all — without one, an <a> isn't clickable. Destinations can be another page, a section on the same page (#some-id), or an external site.

Images use <img src="path" alt="description" /> — note there's no closing tag, since an image has no content to wrap. The alt attribute is not optional decoration: it's the text a screen reader announces instead of the image, and the text a browser shows if the image fails to load. A purely decorative image (like a background flourish) can use alt="" to be explicitly skipped; anything meaningful needs a real description.

Lists

  • <ul> (unordered list) is for items with no inherent order — a set of features, ingredients, or links.
  • <ol> (ordered list) is for items where sequence matters — steps in a recipe, rankings.
  • Both wrap individual <li> (list item) elements, and lists can nest inside each other to represent sub-groups.

Tables

Tables exist for tabular data — rows and columns of related values, like a pricing chart or a schedule — never for general page layout (that's what Flexbox and Grid, covered later in this course, are for). A table's shape is: <table> wraps optional <thead> (header row) and <tbody> (data rows); each row is a <tr>; header cells use <th>, data cells use <td>. Marking header cells with <th> instead of <td> isn't just visual — it tells assistive technology which cell labels which column or row.

Reaching for the semantically correct element over a generic <div> costs nothing extra to write, and pays off the moment anyone — human or machine — needs to understand your page's structure rather than just its appearance.

Example

A full page using semantic landmarks, a navigation link list, an image with alt text, and a small table.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Semantic page</title>
  </head>
  <body>
    <header>
      <h1>Trail Guide</h1>
      <nav>
        <a href="#trails">Trails</a>
        <a href="#gear">Gear</a>
      </nav>
    </header>
    <main>
      <section id="trails">
        <h2>Featured trail</h2>
        <article>
          <h3>Ridge Loop</h3>
          <img src="ridge.jpg" alt="A rocky ridge trail above a pine forest" />
          <p>A 6-mile loop with steady climbing and wide views.</p>
        </article>
        <ul>
          <li>Distance: 6 miles</li>
          <li>Elevation gain: 1,200 ft</li>
        </ul>
      </section>
      <table>
        <thead>
          <tr>
            <th>Trail</th>
            <th>Length</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>Ridge Loop</td>
            <td>6 miles</td>
          </tr>
        </tbody>
      </table>
    </main>
    <footer>
      <p>&copy; 2026 Trail Guide</p>
    </footer>
  </body>
</html>

Try it yourself

Add a third navigation link and a third <li> to the list, then press Run.

Code editor. Press Escape then Tab to leave the editor if keyboard focus becomes trapped. Press Control+Shift+M inside the editor to toggle Tab-key focus trapping.

Loading editor…

Guided exercise

Guided exercise

Add a <nav> inside <header> containing at least two <a> links, and give the existing <img> a meaningful, non-empty alt attribute.

Checks: Adds a <nav> inside <header> · The <nav> has at least two links · plus 1 hidden check

Code editor. Press Escape then Tab to leave the editor if keyboard focus becomes trapped. Press Control+Shift+M inside the editor to toggle Tab-key focus trapping.

Loading editor…

Stuck? Get a hint.

Independent exercise

Independent exercise

Build a semantic page: a <header> with a <nav> containing at least two links, a <main> containing one <article> and one <aside>, a <ul> with at least three <li> items somewhere on the page, and a <footer>.

Checks: Header contains a nav with 2+ links · Main contains an article · Main contains an aside · A list with at least 3 items exists · plus 1 hidden check

Code editor. Press Escape then Tab to leave the editor if keyboard focus becomes trapped. Press Control+Shift+M inside the editor to toggle Tab-key focus trapping.

Loading editor…

Stuck? Get a hint.

Common mistakes

  • Using <div> everywhere instead of header, nav, main, article, aside, or footer when a more descriptive element clearly fits.
  • Leaving alt attributes empty or filled with unhelpful text like 'image123' on meaningful images, instead of a real description.
  • Building a table without <th> header cells, so assistive technology has no way to know what each column or row represents.
  • Using a link with no real href, or a <div> with a click handler, where a proper <a href="..."> would be both simpler and more accessible.

Knowledge check

Knowledge check

1. Which element should wrap a self-contained piece of content, like a single blog post?
2. What is the purpose of an <img>'s alt attribute?
3. In a table, what is the difference between <th> and <td>?
4. Which element makes text into a clickable link?

Takeaway

Choosing the semantically correct element instead of a generic div costs nothing to write, but tells browsers, search engines, and assistive technology exactly what each part of your page means.

Summary

Semantic landmarks like header, nav, main, article, aside, and footer describe the role of each page region instead of relying on meaningless divs. Links need a real href, images need meaningful alt text, lists come in ordered and unordered flavors, and tables should be reserved for genuinely tabular data with properly marked header cells.

References

Your notes

Notes save automatically.

Finished this lesson?

Mark it complete to track your progress and schedule a future review.