HubSpot is committed to making sure that we have provided the necessary tools to help you make your content accessible. While not a definitive guide, here are some steps that you can take to make your content accessible.
<img>
element that the alt text the user provides is actually used.
src
attribute of images to be something untrue (like a small .gif
file) instead of the true source of the image, which is held in a data-src
attribute until the user scrolls the image close to view. This means that initially the image is inaccessible to a screen reader user who is navigating the page, especially one using a rotor to look through the entire page’s contents without even scrolling. Additionally, if JavaScript isn’t loaded on a page, these lazy loading solutions will fail, and therefore, leave assistive technology users without the proper images on the page.
Using native image lazy loading avoids this problem, keeping the image markup the same, regardless of whether JavaScript loads.
'display: none'
to hide form labels and other descriptive text. This prevents text from being read aloud for those with difficulty seeing, as well as hurts users who can see but have trouble seeing the text due to lack of contrast on the placeholder text. Not to mention, who hasn’t started filling out a form or had a form get auto-filled for them, but had no idea if it was entered correctly because the form field labels were invisible.
If you absolutely have to have hidden text or hidden text could provide additional context that a sighted user wouldn’t need. Use CSS that makes the text invisible without hiding it from screen readers or add the '.screen-reader-text'
class.
<header>
, <main>
, <footer>
, <nav>
, <time>
, <code>
, <aside>
, and <article>
.
Some examples of elements that are not semantic are <div>
and <span>
. Non semantic elements still have their place, but should be used primarily for presentation and not for conveying meaning.
Semantic elements can be understood by search engines and assistive technologies, both positively affecting SEO and improving your user experience.
Do not use <div>
elements as interactive elements like buttons, tabs, or links unless you’re sure you’ve provided a good experience via aria attributes.
Use links (<a />
) and <button />
appropriately.
Use links for linking to sections of a page and navigating to other pages.
Use Buttons for interactions that do not result in leaving the page or navigating to an ID.
When working with tables - if a table has a descriptive title include it in a <caption>
element just after the <table>
element.
Use <th>
elements with the proper scope attribute in tables for column and row headings and <thead>
, <tbody>
, and <tfoot>
to denote sections.
Use the scope attribute on <th>
attributes to denote whether the heading is for the row or column.
Need an accordion? Don’t forget about the <details>
and <summary>
elements they give you most of this functionality for free, and it’s accessible. Be sure to add a polyfill or fallback if you need to support old browsers.
hidden
, aria-expanded
, aria-current
, aria-selected
, and other state attributes as necessary to ensure screen readers properly communicate the state of elements.<header>
, <main>
, <footer>
, <nav>
, <dialog>
, etc.) to communicate to web browsers and screen readers what type of content is inside your elements.
In the off-chance semantic elements are not appropriate for your scenario you should add role attributes.
Adding landmarks make it easier for users that are using screen readers to jump between the major sections of a web page. HubSpot includes ‘role’ attributes to the menu, simple menu, and Google Search modules.
<h1>
<h2>
etc. and nest them consecutively. Do not skip a heading for visual effect.<mark>
<strong>
<em>
<sup>
etc. semantic tag, otherwise your meaning may be lost to some visitors.