6 Alternative Text
6.1 What is Alternative Text?
Alternative text, or “alt text,” describes images for users with visual impairments. Screen readers use alt text to convey the meaning of images. You have to include alternative text for every image to meet digital accessibility standards.
6.2 How to Generate Alt Text for Images
Before you start creating alt text, keep in mind the that the goal is to clearly describe the essential content of the image. Keep the text short and clear. It should be enough for a screen reader to read without excessive detail. Try not to repeat nearby text, such as a caption. It is also unnecessary to use phrases such as “image of…” or “graphic showing…”
There are several ways to add alternative text to image in Quarto (and R Markdown).
For external images that are loaded, add the alt text in square brackets.
For plots created with R code, add the fig.alt option to the brackets defining the code chunk in R Markdown.
{r, fig.alt="alt text description"}
ggplotIf using Quarto format, add the fig-alt option.
#| fig-alt: "alt text"
knitr::include_graphics()For the cover of the book, add the following options the book section of _quarto.yml.
book:
cover-image: cover.png
cover-image-alt: "alt text description"6.2.1 Tip: Use AI to Draft Alt Text
You can ask generative AI to help generate alt text for you.
Prompt: Please generate alternative text for this image. It must follow the WCAG standard. Use the provided context or code if available. Keep it short and focused on the essential meaning of the image. Do not exceed the recommended character limit.
6.3 Resources
R Markdown and Quarto resources:
Alt text guidelines: