What Developers Need to Know About HTML Accessibility
Web accessibility has become an integral part of doing business online, but it can be a lot more time-consuming to implement if you leave it too late.
Disabled users require specific functionality to be able to engage with a website in the same way that other users do, which is where accessibility comes in.
A best practice is to take accessibility into account right from the start – before you even begin the development process. This will ensure that you don’t need to scramble to make complex changes later on.
In this article, we will cover some basic HTML5 accessibility guidelines that will help you create a site that complies with WCAG regulations.
For more detailed information on WCAG and compliance, read this guide to achieving ADA compliance.
Let’s start with some of the basic steps you would take to make an HTML-based site accessible.
Add Alt Text
For a site to be compatible with screen readers, it’s important to add text alternatives, or alt text, to your images. This tag is added as an attribute to the <img> tag and gives the image more context.
An example would be <img src=”https://examplewebsite.com/file:roses.jpg” alt=”A bunch of red roses“/>
If a user accesses a website with a screen reader, it would read this alt tag aloud, ensuring they know exactly what’s on their screen. This is also why it’s important to use clear alt text.
Incorporate the Correct Semantic Tags
As an HTML developer, you already know what semantic tags are, but how you use them will change when you are developing an accessible website.
For example, <b> and <strong> tags do the same thing and are interchangeable. However, this is not the case in terms of accessibility.
On an accessible website, <b> indicates how text should look, while <strong> denotes how text should be understood. Basically, a screen reader will interpret each of these tags differently and read them out differently too.
Overall, if you are using semantic tags on a site, make sure that you’re using the same pairs to create a more accessible site.
Also known as Accessible Rich Internet Applications, ARIA consists of a series of markup extensions that can be added to elements to provide screen readers with more information on them.
In turn, this ensures that visually impaired users have a better idea of what’s appearing on a webpage.
For example, an ARIA attribute can indicate the role or function that a particular element has on a page. Navigation bars, forms, and checkboxes are all examples of elements that you can apply ARIA to. It can also help with HTML table accessibility.
To make a website accessible, make a point of adding ARIA attributes to any elements that you feel will give screen readers and users more context. You can find detailed documentation on ARIA attributes in this guide to HTML accessibility.
Now that you know the basics you need to cover, let’s delve into some additional steps you can take to achieve HTML accessibility.
You will also find this general ADA compliance checklist useful during this process.
Only Use Container Elements for Layouts
In terms of accessibility, it’s important to only use <div> and <span> tags for layouts. The reason for this is that assistive technology doesn’t interact with these tags. So, by using <div> or <span> around important elements such as a form or button, a user will miss out on them completely.
Develop with the User in Mind
Understandably, HTML elements are used to create specific designs and alter graphics. However, if you want a site to be accessible and compliant, it’s best to only use HTML elements in the way that you’re meant to. This ensures that assistive technology and browsers are interpreting each element correctly.
Use the Correct Headings
Headings are one of the most important elements on any site. Not only do search engines rely on headings to understand your site, but visitors use them to skim your pages.
Using the correct headings on your site creates a better structure and highlights the relationship between different sections – it’s also what helps screen readers navigate and understand your site.
- <H1> is reserved for your main headings and you should only use one per page.
- Your header tags should always be in the correct order. <H1> should be followed by <H2>, which should be followed by <H3> etc.
- You shouldn’t skip levels when you’re increasing the size of your headers but you can when you’re decreasing them.
Declare the Language
The final tip on this list is to always include the lang attribute inside the <html> tag on your site – this ensures assistive technology knows what language to expect. It’s also best to include this attribute for SEO purposes.
In the end, you want to provide website visitors with the most seamless experience possible, including those living with disabilities.
Web accessibility is no longer something we can ignore, especially with so many people relying on the internet to perform day-to-day activities.
Coding an HTML website with accessibility in mind is one of the fastest and easiest ways to achieve WCAG and ADA compliance. And the guidelines mentioned above are the best place to start!
Find out whether your HTML website is accessible or not by conducting a test on Accessibility Checker
Want to learn more about accessibility and the web design process? Here are some recommended blogs:
Scan your website for accessibility related issues for free