Empty alt attribute for decorative images

Table of contents

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 #

  1. Meaningful vs. Decorative Images:
    • Meaningful Image: The company logo (alt="Company logo: TechSmart") provides important branding information and is assigned a descriptive alt text.
    • Decorative Image: The leaf divider (alt="") is purely decorative, adding visual separation to the content but no essential information. The empty alt attribute (alt="") instructs screen readers to ignore it.
  2. Why Use an Empty alt Attribute:
    • Images without an alt attribute will cause screen readers to announce them as “image,” which can be confusing or disruptive.
    • The empty alt attribute (alt="") explicitly tells screen readers that this image should be ignored, improving the reading flow for users who rely on audio output.
  3. When to Use Empty alt Attributes:
    • 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

Key Takeaways #

  • Use alt="" for Decorative Images: Decorative images should have an empty alt attribute to prevent screen readers from announcing them.
  • Differentiate Essential and Decorative Images: Provide meaningful alt text for images that add value to the content and an empty alt for 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:

What are your feelings

Updated on March 6, 2025