Skip to content
BENIBIX Learn

Semantic HTML Elements

Level 2 · HTML

Why a nav, a main and a button beat a pile of div tags. How the right tag helps screen readers, keyboards and search engines.

Course contentsLesson 5 of 14

After this lesson you can

  • Pick a semantic tag for each part of a page
  • Explain what a screen reader gets from it
  • Say why a button beats a clickable div

10 mincovers 4 glossary entries

Worth reading first: HTML Elements and Attributes

Why the right tag matters more than the look

Semantic HTML means picking the tag that says what each part of a page is. A menu goes in <nav>, the main content in <main>, and a button in <button>. A <div> says nothing at all. A page can look the same both ways, but only one of them can be understood by a machine.

The main parts of a page each have a tag. The <header> holds the logo and the top links. The <nav> holds the menu. The <main> holds what the page is about, and there should be one. An <article> is a piece that stands alone, such as a post. The <footer> sits at the bottom.

A screen reader is the first to gain. It is an app that reads the page out loud for people who cannot see it. It lists the headings and the main parts, so a user can jump straight to <main> or to the third heading. With only <div> tags, there is nothing to jump to.

The right tag also brings free behaviour. A <button> can be reached with the Tab key and pressed with Enter or Space. A <div> made clickable with JavaScript can do neither until you add all of it by hand. Most people who build it that way never do.

Headings work the same way. Use one <h1> for the page title, then <h2> for each section and <h3> inside those. Do not skip from <h1> to <h4> because the smaller size looks nice. The levels are an outline, and screen readers and search engines read them as one.

There is a set of labels called ARIA that can tell a screen reader what a <div> is meant to be. It is a patch, not a first choice. The first rule of ARIA is to use a real HTML tag when one exists. That tag already has the meaning and the keyboard support.

All of this is a big part of accessibility: making a thing that everyone can use. It is not extra work for a few users. A page with clear tags is easier to search, easier to style and easier for the next coder to read.

Both pages look the same. Only the one on the right tells a machine what each part is.

Worked example

Lucy fixes a menu nobody could reach

Lucy's shop menu was built from 8 <div> tags that opened on a click. Keyboard users pressed Tab 30 times and never reached it.

She swaps them for a <nav> holding real <button> and <a> tags. Now Tab reaches the menu in 2 presses, and a screen reader announces it as navigation.

The words for this lesson4

Check yourself

Why use a <button> tag instead of a clickable <div>?

Finished this lesson?

Marking it complete also marks its 4 glossary entries learned, which updates your roadmap and your saved page. 0 are already marked.