Sub topic 8
Marking up the page with semantic HTML
This chapter assumes you know basic HTML tags and attributes, can read a simple page structure, and understand URLs. It covers how to mark up a newsroom page so that browsers, screen readers, search engines and feed tools can understand its structure without guessing.
Why semantics matter for a newsroom
Semantic HTML means choosing elements for what content is, not for how it looks. A <div> says nothing about its content. An <article> says "this is a self-contained item," and a <time> says "this is a date a machine can read."
A newsroom page gets three kinds of readers:
- Journalists, who scan for the latest release, a contact and downloads.
- Assistive technology, such as screen readers, which uses the page structure to let users jump between sections.
- Crawlers and tools, which extract titles, dates and links.
Good markup serves all three at once. Later chapters build on it: link previews, JSON-LD, RSS and accessibility checks all assume the structure is already sound.
Landmarks and sectioning
Landmark elements mark the major regions of a page. Screen reader users can list landmarks and jump straight to one.
| Element | Role it exposes | Newsroom use |
|---|---|---|
| `<header>` | Banner (when a direct child of `<body>`) | Logo, site navigation |
| `<nav>` | Navigation | Newsroom section links |
| `<main>` | Main content | The newsroom itself. Use one per page. |
| `<section>` | Region (only when it has an accessible name) | Press releases, Media contact |
| `<article>` | Article | One release or news post |
| `<aside>` | Complementary | Related links, boilerplate sidebar |
| `<footer>` | Contentinfo (when a direct child of `<body>`) | Legal, copyright |
Two rules cause most mistakes:
- One
<main>per page. It holds the content unique to this page, not the site header or footer. - A
<section>needs a name. Without one, it is a generic grouping and is not exposed as a landmark. Pointaria-labelledbyat the section's heading to name it.
Here is a newsroom page body that follows both rules.
<main id="newsroom">
<h1>Acme Newsroom</h1>
<section aria-labelledby="releases-heading">
<h2 id="releases-heading">Press releases</h2>
<article>
<h3><a href="/newsroom/acme-launches-widget-2">Acme launches Widget 2</a></h3>
<p><time datetime="2026-03-12">March 12, 2026</time></p>
<p>Widget 2 cuts setup time for small teams.</p>
</article>
</section>
<section aria-labelledby="contact-heading">
<h2 id="contact-heading">Media contact</h2>
<p>Jordan Lee, <a href="mailto:[email protected]">[email protected]</a></p>
</section>
</main>Each section is named by its own <h2>. Each release is an <article> because it makes sense on its own, for example when syndicated or read in a feed reader.
Headings form an outline
Screen reader users often navigate by heading level, so levels must reflect real hierarchy.
- Use one
<h1>for the page title. - Use
<h2>for each major section and<h3>for items within it. - Never skip a level to get a smaller font. Change the size with CSS instead.
- Do not use a heading for text that is only bold, such as a caption.
On a single release page, the release headline becomes the <h1>. On the newsroom index, each release title is an <h3> link under the "Press releases" <h2>, as above. The same release therefore uses a different heading level depending on the page. That is correct, because the level describes position in that page's outline.
Dates with the time element
The <time> element pairs human-readable text with a machine-readable value in datetime.
<p>Published <time datetime="2026-03-12T09:00:00Z">March 12, 2026</time></p>The visible text can be formatted for readers. The datetime attribute must use a valid format: 2026-03-12 for a date, or a full timestamp with a time zone such as 2026-03-12T09:00:00Z. Use a time zone on timestamps, because a release scheduled for 9:00 in one city is a different moment elsewhere. Keep the datetime value consistent with the JSON-LD datePublished and the RSS pubDate, which later chapters add.
Links that make sense out of context
Screen reader users can list every link on a page. A list of "Read more" or "Download" links is useless in that view.
- Make the link text describe the target: "Download logo pack (ZIP, 4.2 MB)", not "Click here".
- Wrap the headline in the link, as the example does, instead of adding a separate "Read more".
- Use
mailto:for the contact address, and show the address as the link text so people can copy it. - For download links, state the file type and size in the text, so users know before they click.
<ul>
<li><a href="/newsroom/assets/acme-logos.zip">Acme logo pack (ZIP, 4.2 MB)</a></li>
<li><a href="/newsroom/assets/acme-fact-sheet.pdf">Fact sheet (PDF, 180 KB)</a></li>
</ul>A list is the right container for a set of related downloads, because assistive technology announces "list, 2 items."
Images and figures
Press photos are content, so they need text alternatives.
- Give each informative image an
altattribute that says what it shows. - Use
alt=""for purely decorative images so screen readers skip them. - Use
<figure>with<figcaption>when a photo has a caption or credit that belongs with it.
<figure>
<img src="/newsroom/img/ceo-headshot-800.jpg"
alt="Jordan Lee, chief executive of Acme, smiling in front of a window"
width="800" height="1000">
<figcaption>Jordan Lee, CEO. Photo: Acme.</figcaption>
</figure>The width and height attributes let the browser reserve space before the image loads, which prevents layout shifts. The performance chapter returns to this.
The document head
The <head> does not render, but it carries the facts every tool reads first. Set the language on the root element, and give each page a unique title and description.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Acme launches Widget 2 | Acme Newsroom</title>
<meta name="description" content="Widget 2 cuts setup time for small teams.">
</head>langtells screen readers which pronunciation rules to use.- The
<title>is the first thing a screen reader announces and the text shown in a browser tab and search result. Put the specific item first and the site name last. - The viewport tag makes the page usable on phones, where many journalists read links.
The next chapters add canonical, Open Graph, and feed links to this same <head>.
Common errors
| Mistake | Effect | Fix |
|---|---|---|
| `<div>` or `<span>` used as buttons or links | Not focusable by keyboard, not announced correctly | Use `<a href>` for navigation and `<button>` for actions |
| Several `<main>` elements | Landmark list is ambiguous | Keep one per page |
| `<section>` with no heading or name | Not exposed as a landmark | Add a heading and `aria-labelledby` |
| Skipped heading levels | Broken outline | Follow h1, h2, h3 in order |
| Release date as plain text | Machines cannot read it | Wrap in `<time datetime>` |
| "Read more" links | Meaningless in a link list | Link the headline or use descriptive text |
| Missing `alt` | Image is announced as a file name, or ignored | Write a description, or `alt=""` if decorative |
Checking your markup
Test the structure rather than trusting it.
- Run the page through the W3C Nu HTML Checker to catch invalid nesting and bad
datetimevalues. - Open the browser's accessibility tree view in developer tools and confirm each landmark has the name you expect.
- Tab through the page with the keyboard. Every link must receive focus in a logical order.
- Turn off CSS, or use a reader mode. The content should still read in a sensible order.
How the pieces fit
The diagram shows how the semantic structure sits under the other layers this tutorial adds.
Titles, dates and headlines marked up once in the page can be reused by each of the later layers, so keeping them consistent saves work.
Exercise
A newsroom index lists three releases under a section headed "Press releases". A developer wrote each release as a <div> with an <h4> title, and wrote the date as plain text. Name four changes that make the markup semantic and accessible.
Show answer
(1) Wrap the list in a <section> named with aria-labelledby pointing to its <h2>. (2) Change each release <div> to an <article>. (3) Change the <h4> titles to <h3> so no heading level is skipped, and put the link inside the heading. (4) Wrap each date in <time datetime="YYYY-MM-DD">.
Exercise
Why is the link text "Download" a problem on a page with five downloadable files, and what would you write instead?
Show answer
Screen reader users can list all links on a page, and five identical "Download" entries cannot be told apart. Write descriptive text that names the file, type and size, such as "Acme logo pack (ZIP, 4.2 MB)".