Context: Visually a list of links.
Bad code
<h6>Popular Cities</h6>
<div>
<h6 class="footerLinks">Amsterdam</h6>
<h6 class="footerLinks">Rotterdam</h6>
<h6 class="footerLinks">Utrecht</h6>
<h6 class="footerLinks">Den Haag</h6>
<h6 class="footerLinks">Eindhoven</h6>
</div>
Issues and how to fix them
- Use headings (
<h1>
-<h6>
) to structure the page, don’t use heading elements arbitrarily or only to comply with visual requirements. - By default, a click event on an
<h6>
triggers only on click. A click event on ana
triggers on click and if the user presses the Enter key. - An
<h6>
isn’t keyboard focusable. - If your content it so comprehensive and deeply structured that you need levels as deep as
<h5>
and<h6>
in order to describe the structure, consider splitting your large page into multiple smaller pages. - The
<div>
element is an element of last resort, for when no other element is suitable. Use of the<div>
element instead of more appropriate elements leads to poor accessibility. - If you’re listing items that thematically belong together, consider grouping them semantically using
<ol>
or<ul>
. <a>
allows users to right click and copy link / open in new tab.- Linking to pages using the
<a>
element works without JavaScript. - An
<a>
has the right cursor without having to add CSS.
Check out the resources section at the bottom of this page for more.
Good code
<h3>Popular Cities</h3>
<ul>
<li>
<a href="/amsterdam.html">Amsterdam</a>
</li>
<li>
<a href="/rotterdam.html">Rotterdam</a>
</li>
<li>
<a href="/utrecht.html">Utrecht</a>
</li>
<li>
<a href="/denhaag.html">Den Haag</a>
</li>
<li>
<a href="/eindhoven.html">Eindhoven</a>
</li>
</ul>