Skip to content

Instantly share code, notes, and snippets.

@laurelstreng
Created March 6, 2025 15:18
Show Gist options
  • Save laurelstreng/865cc4946ad4f57266b3a825b45647ed to your computer and use it in GitHub Desktop.
Save laurelstreng/865cc4946ad4f57266b3a825b45647ed to your computer and use it in GitHub Desktop.
Add alternative text to pseudo elements
/**
* Adding alternative text for screen readers to pseudo elements.
*
* https://developer.mozilla.org/en-US/docs/Web/CSS/content#adding_an_image_with_alternative_text
**/
.location {
&::before {
/* fallback content */
content: url(images/backgrounds/location.svg) ' - Alt text is not supported';
/* content with alternative text */
content: url(images/backgrounds/location.svg) / ' Blue outlined location pin icon';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment