Empty Alt Attribute for Decorative Images
Description:
When an image is purely decorative and does not convey meaningful information, it’s best practice to use an empty alt attribute (alt=""). This tells screen readers to skip the image, improving the browsing experience for users who rely on assistive technologies by reducing unnecessary audio feedback. Decorative images might include background graphics, spacers, or embellishments that do not add context or essential information to the content.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example of Decorative Image with Empty Alt Attribute</title>
</head>
<body>
<!-- Logo with meaningful alt text (for comparison) -->
<header>
<img src="images/logo.png" alt="Company logo: TechSmart" width="100" height="50">
</header>
<!-- Decorative image with empty alt attribute -->
<section>
<img src="images/leaf-divider.png" alt="" width="300" height="10">
<p>Welcome to our eco-friendly product collection. Browse our items with a minimal environmental impact.</p>
<img src="images/leaf-divider.png" alt="" width="300" height="10">
</section>
</body>
</html>
Explanation #
- Meaningful vs. Decorative Images:
- Meaningful Image: The company logo (
alt="Company logo: TechSmart") provides important branding information and is assigned a descriptivealttext. - Decorative Image: The leaf divider (
alt="") is purely decorative, adding visual separation to the content but no essential information. The emptyaltattribute (alt="") instructs screen readers to ignore it.
- Meaningful Image: The company logo (
- Why Use an Empty
altAttribute:- Images without an
altattribute will cause screen readers to announce them as “image,” which can be confusing or disruptive. - The empty
altattribute (alt="") explicitly tells screen readers that this image should be ignored, improving the reading flow for users who rely on audio output.
- Images without an
- When to Use Empty
altAttributes:- Use empty
alt=""for images that are purely decorative or non-informational, such as:- Background images
- Visual dividers, icons, or embellishments that don’t add content
- Images used only for aesthetic purposes without context
- Use empty
Key Takeaways #
- Use
alt=""for Decorative Images: Decorative images should have an emptyaltattribute to prevent screen readers from announcing them. - Differentiate Essential and Decorative Images: Provide meaningful
alttext for images that add value to the content and an emptyaltfor those that don’t. - Improves Accessibility and User Experience: Skipping decorative images reduces clutter in screen reader output, making the experience smoother and more focused.
Screen reader: NVDA
Video: