What semantic means in HTML
Permalink:Suppose the library posts its Saturday opening hours.
You can put the label "Saturday hours" in a div and make the letters large and bold.
On screen, that might look the same as an h2.
The difference shows up in a screen reader's heading list.
The h2 is a place to jump to.
The styled div is just a container.
A class name can say what the code is for.
But a class called section-title does not give an element a heading role.
Start by reading the page as if it were an outline.
For a page about visiting the library, "Plan your visit" could be the h1.
"Saturday hours" and "Getting here" can be two h2 headings.
If "Getting here" has directions by bus and by bike, those can be h3 headings under it.
Pick the level from how the topics relate.
Then use CSS to make each heading the size you want.
Changing an h2 to an h4 to get smaller letters makes the structure harder to follow.
Some elements also bring behavior.
An a with an href can take someone to the library's directions page.
The browser then lets people copy the address or open it in a new tab.
A button can open a menu on the current page.
It works with a keyboard.
You do not have to teach a div to respond to keys.
For the menu to open, you still need to connect the button to that behavior.
The elements that earn their keep
Permalink:Use main for the content that makes this page different from the other pages on the site.
On the library's visit page that means the hours and directions.
It does not mean the site menu that appears on every page.
Use one visible main and put major groups of navigation links in nav.
A single link to the bus timetable in a paragraph can stay where it is.
A page-level header can hold the site name and the menu.
A page-level footer can hold contact or copyright information.
An article can also have its own header for a headline and byline.
It can have its own footer for a credit.
Use article for a piece that could stand on its own, like a news item about an upcoming library closure.
Use section for a distinct part of a larger whole.
It usually has a heading, such as the directions on the visit page.
Use aside for related material outside the main thread, such as a note about another nearby branch.
The same decisions apply inside those regions.
Use ul for several options where the order does not matter.
Use ol for instructions people must follow in order.
A table makes sense when someone needs to compare which branches are open on which days.
Use labeled header cells that tie each time to its branch and day.
Use paragraphs for prose.
Use a label for a form field.
Then people can tell what to enter even after a placeholder disappears.
Keep a div when all you need is a wrapper for layout.
If it groups the hours and directions so CSS can put them in two columns, it has a useful job.
It is not a section of its own.
A span can style a few words inside a sentence.
It does not give those words a new role.
When you see a container named nav, heading, or button, ask whether the matching HTML element could do the job itself.
Before and after: div soup vs meaning
Permalink:Here is a fragment of the visit page built from generic containers. It relies on its classes for appearance. The two labels look like links, but they do not work as navigation.
<div class="site-header">
<div class="site-name">Cedar Library</div>
<div class="menu">
<div class="menu-link">Hours</div>
<div class="menu-link">Directions</div>
</div>
</div>
<div class="content">
<div class="page-title">Plan your visit</div>
<div class="section-title" id="hours">Saturday hours</div>
<div>Open from ten to four.</div>
<div class="section-title" id="directions">Getting here</div>
<div>Use the Oak Street entrance.</div>
</div>
Keep the same information and mark up each part for its job.
These are body fragments.
Put each version inside the body of its own HTML file to try it in a browser.
<header class="site-header">
<p class="site-name">Cedar Library</p>
<nav class="menu" aria-label="On this page">
<a class="menu-link" href="#hours">Hours</a>
<a class="menu-link" href="#directions">Directions</a>
</nav>
</header>
<main class="content">
<h1 class="page-title">Plan your visit</h1>
<h2 class="section-title" id="hours">Saturday hours</h2>
<p>Open from ten to four.</p>
<h2 class="section-title" id="directions">Getting here</h2>
<p>Use the Oak Street entrance.</p>
</main>
The class names can stay.
Rules that target those classes can still apply.
Check your stylesheet for selectors like div.menu-link.
They need to match the new element before you can compare the two designs.
Browsers give headings and paragraphs their own default margins.
Expect a difference in spacing until you set the margins you want.
On the revised page, press Tab to reach "Hours," then Enter to follow it.
The address should end in #hours.
This works even when the page is too short for the browser to scroll to the heading.
A heading is a valid link target without being a separate control in the Tab order.
In the first version, none of the containers will be a Tab stop on their own.
That test shows what changed even if you style both versions to look alike.
Landmarks and screen readers
Permalink:Landmarks are named page regions.
Assistive technology can offer them as navigation shortcuts.
The W3C's ARIA in HTML and HTML Accessibility API Mappings describe how native elements supply these roles.
main maps to the main landmark.
nav maps to navigation.
A page-level header and footer can provide the banner and content information landmarks.
The ones inside an article do not provide those page landmarks.
A section can become a region landmark when it has an accessible name, such as one supplied by aria-labelledby pointing to its heading.
A heading inside a section does not give the section that name by itself.
Label navigation landmarks when visitors need to tell different menus apart. For instance, the library may add a site-wide menu above the on-page links. Give it a distinct name such as "Library site." People using a landmark list can then choose between the site navigation and "On this page." Save named regions for places readers will want to jump to. Label every block and the landmark list gets harder to scan.
In the browser's accessibility inspector, look for the navigation and main landmarks. Check the heading levels too. With a screen reader, try to find Saturday hours using headings, then try the same task using landmarks and links. The headings may be right and the page can still fall short. If you cannot reach the links by keyboard, you have a problem to fix. The HTML accessibility guide covers keyboard focus and testing controls in more depth.
How meaning helps search
Permalink:Use a descriptive page title and a main heading.
They should tell readers what they will find.
Use real links for pages they can visit next.
Google's Search Central documentation on crawlable links recommends an a element with an href and descriptive link text.
In the library example, a separate directions page could be linked as "Bus and bike directions."
The destination is then clear without reading the rest of the paragraph.
A search engine can follow a link and read a page's text.
That is separate from how it ranks the page.
Changing every div to a section cannot make a page about another subject answer a search for library hours.
Write the hours as text on the page and use a heading that helps someone find them once they arrive.
For historical context, the ARIA test inventory from the 2007-2009 archive records how people planned to test the structure and behavior exposed by common widgets. In the original mailing list discussion, contributors debated how nested sections should affect numbered headings in HTML5. Read that exchange as a record of a design debate. Then test explicit heading levels in the browser and assistive technology you support today. To practice on another page, pick a sample from the Learn HTML hub. Find its main content by reading the headings before looking at any CSS.