Sub topic 13
Building the page with semantic, accessible HTML
This chapter assumes you know basic HTML and CSS. You should also know what a landing page is and what a conversion is. Earlier chapters covered what each section says. This chapter covers how to mark it up so browsers, screen readers, and search engines can read it.
Why markup matters on a landing page
Semantic HTML means choosing elements for what the content is, not for how it looks. A <h1> is the page's main heading. A <a> is a link. Assistive technology such as a screen reader uses these elements to build an outline of the page. A visitor who cannot see the screen can then jump from heading to heading and find the call to action (CTA).
If every block is a <div>, that outline disappears. The page may look fine and still be hard to use for some visitors.
The skeleton
The skeleton follows the reading order from the earlier chapters: hero, proof, offer.
<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>Points to notice:
<main>wraps the page's unique content. Use it once per page.- There is one
<h1>, the headline. Each later section starts with an<h2>. Do not skip heading levels to get a different font size. Change the size with CSS. aria-labelledbypoints to the id of the section's heading. This gives the section an accessible name, so a screen reader can list it as a landmark.<figure>,<blockquote>, and<figcaption>tie a quote to the person who said it.- The CTA is an
<a>with anhref, because it navigates to the signup page. Use<button>only for actions that happen on the current page, such as submitting a form.
A visible, usable button
A CTA must stand out and work from the keyboard. Keep strong contrast between the text and background. Never remove the focus outline without replacing it.
.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;
}:focus-visible shows the outline when someone navigates by keyboard. Mouse clicks usually do not trigger it. White text on #0b5fff meets the WCAG AA contrast ratio of 4.5:1 for normal text. Check your own colors with a contrast checker.
Marking CTAs for measurement
The data-cta attribute names each placement. A small script reads it so you can tell which button was clicked.
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. Both buttons share the same label and destination. Only the data-cta value differs.
Common errors
| Error | Problem | Fix |
|---|---|---|
| Several `<h1>` elements, or none | The outline has no clear main topic | Use one `<h1>` for the headline |
| Headings chosen by size | Screen reader users lose the structure | Pick the level by structure, style with CSS |
| `<div class="button">` with a click handler | No keyboard access, no link behavior | Use `<a href>` |
| Removed focus outline | Keyboard users cannot see where they are | Style `:focus-visible` |
| Vague link text such as "Click here" | Meaningless in a list of links | Use a specific label |
Exercise
A teammate builds the CTA as <div class="button" onclick="location='/signup'">Start your free trial</div>. Name two problems and give the fix.
Show answer
A <div> cannot receive keyboard focus and is not announced as a link, so keyboard and screen reader users cannot use it. Replace it with <a class="button" href="/signup">Start your free trial</a>, which is focusable, works with Enter, and is announced as a link.
Exercise
Why does each <section> in the skeleton use aria-labelledby pointing to its <h2>?
Show answer
It gives the section an accessible name taken from its visible heading, so assistive technology can list it as a named landmark without duplicating the text.