Sub topic 13
Building the Page with Semantic, Accessible HTML
This chapter assumes you know basic HTML and CSS, and that you have already drafted the headline, proof, offer, and call to action (CTA) for a single-goal page. Here you turn that plan into markup that browsers, screen readers, and search engines can all read correctly.
Why markup matters on a landing page
A landing page has one job: get the visitor to take one action. Markup affects that job in three ways.
- Visitors who use a keyboard or a screen reader must be able to find the headline, read the proof, and activate the CTA.
- Semantic elements give assistive technology a map of the page without extra code.
- Clear structure keeps the reading flow (headline, proof, offer, CTA) the same in the source as on screen.
Semantic HTML means choosing elements by their meaning, not their looks. A <button> or <a> is a control. A <ul> is a list. A <h2> is a section heading. Styling is the job of CSS.
The page skeleton
The example below follows the reading order of the page: hero, proof, offer. The product, quote, and trial terms are fictional placeholders.
<main>
<section class="hero">
<h1>Send invoices in under a minute</h1>
<p class="subhead">Example Invoice helps freelancers create, send, and track invoices without a spreadsheet.</p>
<a class="button" href="/signup" data-cta="hero">Start your free trial</a>
<p class="note">14-day trial. No credit card required.</p>
</section>
<section aria-labelledby="proof-heading">
<h2 id="proof-heading">What customers say</h2>
<figure>
<blockquote>
<p>I stopped chasing late payments after the first week.</p>
</blockquote>
<figcaption>Jordan Lee, freelance designer</figcaption>
</figure>
</section>
<section aria-labelledby="offer-heading">
<h2 id="offer-heading">What you get</h2>
<ul>
<li>Unlimited invoices during the trial</li>
<li>Automatic payment reminders</li>
<li>Cancel any time from your account page</li>
</ul>
<a class="button" href="/signup" data-cta="offer">Start your free trial</a>
</section>
</main>This is a fragment. In a real page it sits inside a full document with <!doctype html>, <html lang="en">, a <title>, and <meta name="viewport" content="width=device-width, initial-scale=1">. The lang attribute lets screen readers choose the right pronunciation rules.
Landmarks and the page outline
Landmarks are regions that assistive technology can list and jump between. The main ones are:
| Element | Landmark role | Use on a landing page |
|---|---|---|
| `<header>` (direct child of `<body>`) | banner | Logo and, if any, minimal navigation |
| `<main>` | main | The single block holding all page content |
| `<section>` with an accessible name | region | A named block such as proof or offer |
| `<footer>` (direct child of `<body>`) | contentinfo | Legal links, contact details |
Rules to follow:
- Use exactly one
<main>per page. - Give a
<section>an accessible name, as the skeleton does witharia-labelledby. A<section>without a name is not exposed as a landmark, so the attribute is what makes it navigable. - Use one
<h1>and make it the headline. Use<h2>for each major section. Use<h3>only for subsections inside those. Do not skip levels to get a font size.
Many people navigate by headings alone. Your headings, read in order, should tell the story: the headline, then "What customers say", then "What you get". If a visitor heard only the headings, they should still understand the page.
Linking the CTA: link or button?
The skeleton uses <a href="/signup"> styled as a button. That is correct when the CTA goes to another URL, such as a signup page. Use a <button> when the control performs an action on the current page, such as submitting a form.
| Situation | Element | Reason |
|---|---|---|
| Goes to a signup or checkout page | `<a href>` | It navigates, so it needs a real URL. Middle-click and "copy link" work. |
| Submits an inline form | `<button type="submit">` | It acts on the form and responds to Enter. |
| Opens a dialog or expands content | `<button type="button">` | It changes the current page. |
Avoid <div class="button"> or <a> without an href. These are not focusable by default and do not respond to the keyboard unless you rebuild that behaviour yourself.
A related rule: the visible label should say what happens. "Start your free trial" works for every user. If you repeat the CTA, as the skeleton does in the hero and the offer, keep the same label. Identical destinations should have identical names. If two links must differ in meaning, make the difference clear in the text, not only in the position on the page.
Making the CTA visible and usable
A CTA needs strong contrast, a clear shape, and a visible keyboard focus indicator.
.button {
display: inline-block;
padding: 0.75rem 1.5rem;
background: #0b5fff;
color: #ffffff;
font-weight: 600;
text-decoration: none;
border-radius: 0.375rem;
}
.button:hover {
background: #0846c2;
}
.button:focus-visible {
outline: 3px solid #111111;
outline-offset: 3px;
}Points to check:
- Contrast. WCAG 2.2 requires at least 4.5:1 for normal text and 3:1 for large text (18.66px bold or 24px regular and above). White on
#0b5fffpasses the 4.5:1 minimum. Verify any color pair you choose with a contrast checker rather than by eye. - Focus.
:focus-visibleshows the outline for keyboard users and usually hides it for mouse clicks. Never writeoutline: nonewithout a replacement. - Target size. WCAG 2.2 sets a minimum target of 24 by 24 CSS pixels (Success Criterion 2.5.8). The padding above gives a comfortable size well beyond that, and a larger target helps on touch screens.
- Not color alone. The button is identified by its shape and padding, not only by its blue background.
Proof and offer markup
Proof has its own semantic elements. A quotation goes in <blockquote>, and the attribution goes in <figcaption>, both inside a <figure>. This ties the quote to its speaker in the structure, not only in the layout.
For the offer, use a real list. A screen reader announces "list, 3 items", which tells the visitor how much is coming. Do not fake lists with line breaks or symbols.
Two cautions:
- Keep the fine print near the CTA, as the
<p class="note">does in the hero. It is text, so it is read in order and can be zoomed with the page. - Do not put essential terms (price, trial length, cancellation) only in an image. Text in images cannot be resized, searched, or read aloud without alternative text.
Images, including the hero visual
Every <img> needs an alt attribute, and the value depends on the image's role.
- A hero screenshot that supports the claim: describe what it shows, such as
alt="Invoice list with three paid invoices and one reminder scheduled". - A purely decorative background shape: use
alt=""so assistive technology skips it, or place it in CSS. - A customer logo in a proof strip: use the company name, such as
alt="Northwind". If the logo is a link, the alt text describes the destination.
Set width and height attributes on images so the browser reserves space before they load. This prevents the layout from shifting under the visitor's cursor, which can cause a mis-click on the CTA.
Hooks for measurement
The data-cta attribute on each link names its placement. It does not change what users see or how assistive technology reads the link, and it lets a script tell the placements apart.
document.querySelectorAll('[data-cta]').forEach((link) => {
link.addEventListener('click', () => {
console.log('cta_click', link.dataset.cta);
});
});Replace console.log with your analytics tool's event call. Because the handler listens for click, it also fires when a keyboard user activates the link with Enter, since browsers dispatch a click event for that. Do not attach handlers to mousedown or touchstart, which miss keyboard users.
Common mistakes
- Several
<h1>elements or none. Use one, and make it the headline. - Headings chosen for size. Use CSS for size. Use the heading level for structure.
- Clickable
<div>elements. They are not keyboard accessible by default. - Removed focus outlines. Keyboard users lose their place.
- Vague link text. Labels like "Click here" say nothing when read out of context in a list of links.
- Placeholder-only form labels. If the page has a form, give each field a real
<label>. A placeholder disappears when the visitor types. - Text sized in fixed pixels that blocks zoom. Use
remunits and do not disable zoom in the viewport meta tag.
Check your understanding
Exercise
A teammate builds the hero CTA as <div class="button" onclick="location.href='/signup'">Start your free trial</div>. Name three problems with it and give the corrected markup.
Show answer
The div is not focusable, so keyboard users cannot reach it. It has no link role, so screen readers do not announce it as something to activate. It has no real URL, so middle-click, "open in new tab", and "copy link" do not work, and it fails if JavaScript is off. The fix is <a class="button" href="/signup" data-cta="hero">Start your free trial</a>, with the .button:focus-visible style from the chapter.
Exercise
A page has an <h1> headline, then a proof section headed with an <h4> because the designer liked the small text, then an offer section headed with an <h2>. What is wrong, and how do you get the same look?
Show answer
The <h4> skips levels, so the outline is broken and heading navigation gives a misleading structure. Change the proof heading to <h2>, matching the offer heading, and use a CSS class to set the smaller font size.
Exercise
The proof section uses <section> with no heading and no aria-labelledby. Why might a screen reader user be unable to jump to it from the landmark list, and what is the smallest fix?
Show answer
A <section> with no accessible name is not exposed as a region landmark. Add a heading with an id, such as <h2 id="proof-heading">, and set aria-labelledby="proof-heading" on the section.