Providing accessibility in our HTML allows our websites to be enjoyed by more users. This can come from making sure that our colour schemes do not clash so that they can be seen well by colour blind users or that our images have an alt description on them so that they can be read by screen readers for visually impaired users.
Alt attributes have been covered in the HTML media section and colour schemes fall under the purview of the CSS accessibility guidelines.
The remaining HTML attribute to consider is the ARIA label. ARIA labels attach a label to an element that has a purpose or behaviour. For instance labelling links with what they do.
<a href="InstagramURL" title="Instagram" aria-label="Go to our Instagram page" target="_blank">Instagram</a>
The aria-labelledby attribute is used in HTML to explicitly associate a label or multiple labels with an element, helping assistive technologies like screen readers convey the right information to users. The value of aria-labelledby should be a space-separated list of element IDs. These elements listed will contain the text content to be used as the label.
Screen readers will read the combined text content of the referenced elements, in order, as the accessible name
for the element with aria-labelledby. In the example below, assistive technology will read: “Main Title
Subtitle” as the accessible name for the
div
as these are the contents of the elements with ids "heading-one" and "heading-two".
<div aria-labelledby="heading-one heading-two">
<h1 id="heading-one">Main Title</h1>
<h2 id="heading-two">Subtitle</h2>
<p>This section contains detailed information.</p>
</div>