Sometimes, we want to add alt attribute for a CSS background image.
In this article, we’ll look at how to add alt attribute for a CSS background image.
How to add alt attribute for a CSS background image?
To add alt attribute for a CSS background image, we use the aria-label
attribute.
For instance, we write
<div role="img" aria-label="adorable puppy playing on the grass">...</div>
to set the aria-label
attribute’s value to the alt attribute text.
Conclusion
To add alt attribute for a CSS background image, we use the aria-label
attribute.