Skip to content

New rule: a11y/svg-img-alt - SVG images marked role="img" with no accessible name #1699

Closed

Description

@nc9

Problem

An inline <svg role="img"> is announced by screen readers as an image. Without a name it is read as "image" or skipped, so a chart, logo or icon that carries meaning is lost. a11y/aria-labels checks SVGs only when they are clickable (onclick or tabindex). Informative SVGs with role="img" are not checked.

Proposal

A page rule, a11y/svg-img-alt, matching the axe-core rule of the same name: every <svg role="img"> needs an accessible name.

Acceptance Criteria

  • An <svg role="img"> with no <title> child, no aria-label and no aria-labelledby fails, and the finding locates the element.
  • An <svg role="img"> with a non-empty direct <title> child passes.
  • An <svg role="img"> with a non-empty aria-label, or an aria-labelledby that resolves to text on the page, passes.
  • An aria-labelledby that points at an ID missing from the page fails.
  • An SVG with aria-hidden="true" or role="presentation" is not assessed.
  • An SVG with no role attribute is not assessed.
  • An SVG that is hidden from view is not assessed.
  • The finding counts each failing SVG once, and a clickable SVG already reported by a11y/aria-labels is not reported twice.
  • The rule has a docs page under docs/rules/a11y/ and appears in the rule catalog and counts.

Activity

  1. added
    enhancement
    size: XS
    rules
    on Nov 11, 2026
  2. added theissue type on Nov 11, 2026
  3. nc9 commented on Nov 11, 2026

    @nc9
    ContributorAuthor

    Shipped in v0.0.176 via 3bc8486 (feat(rules): a11y/svg-img-alt flags svg role=img with no accessible name #1699). Tests, docs page and category index rows are in that release.

    nik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementrulessize: XS

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions