This content originally appeared on Geoff Graham and was authored by Geoff Graham
Images are often wrapped in a figure
. Figures often contain a figcaption
to “represent a caption or legend describing the rest of the contents of its parent
element.” And best practices advise us to use the alt
attribute on an img
to “provides fallback (alternate) text to display when the image specified by the element is not loaded.”
Some things about the relationship between figcaption
and alt
text:
- The
alt
attribute is mandatory, even if it’s empty (""
). Afigcaption
is optional. It’s a good idea to use something like Emmet to auto-generate the tag for you as you type. - The text used for the
alt
attribute should be different from the text contained in afigcaption
. It’s redundant content that is annoying to an end user who has to hear it announced twice. - Marking an image as decorative (
alt=""
) is invalid when afigcaption
is present. That makes a lotta sense to me, as why would you describe the image in one place if it isn’t meant to be announced? - Some screenreaders may announce an image with whitespace used as the
alt
value (alt=" "
). Didn’t know that! Wish I had more ways to test that and hear how it sounds.
This content originally appeared on Geoff Graham and was authored by Geoff Graham
Geoff Graham | Sciencx (2022-09-01T16:09:01+00:00) Some rules for image captions and alt text. Retrieved from https://www.scien.cx/2022/09/01/some-rules-for-image-captions-and-alt-text/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.