Accessibility

Accessibility is an important part of all websites we work on for the best audience expierience.

Use sr-only to hide an element visually without hiding it from screen readers.

Screen reader text

Combine .sr-only with focus:not-sr-only to show the element again when it’s focused (e.g. by a keyboard-only user).

Focusing on text

Background images

While img tags have the alt attribute, there's no alternative for backgorund images. In order for screen readers to learn about the contents of an image, use the following syntax:

Background images alt text

But importantly, if you are applying images to an element that also contains other content, you cannot add the description to the outer div. This would be describing the contents of the element, where in fact there are multiple pieces of content to read.

Don't do this!

Instead create it as a nested element so you can effectively describe both elements.

The proper way to use background images