Skip to main content
Beta: Front-End Checklist is currently in beta. Some issues are still being fixed. Thanks for your patience.

Avoid focusable descendants in role="text" elements

Checks that elements with role='text' have no focusable descendants

Utilities
Quick take
Typical fix time 10 min
  • Elements with `role="text"` should not contain interactive children (links, buttons)
  • Ensure `role="text"` only contains static text content
  • Prevent accessibility "black holes" where interactive items are hidden from screen readers
Why it matters: Using `role="text"` on a container forces screen readers to treat everything inside as a single string of text, which effectively hides any interactive elements from users who rely on assistive technology.

Rule Details

The role="text" attribute, used mainly in VoiceOver-specific edge cases, should only be applied to static text containers. WAI-ARIA 1.2 (opens in new tab) is clear that flattening a subtree this way becomes dangerous once interactive content is involved.

Code Example

<!-- ✅ Correct: Simple text container -->
<div role="text">
  <span>Price: </span>
  <span>$10.00</span>
</div>
 
<!-- ❌ Incorrect: Contains a focusable link -->
<div role="text">
  Learn more at <a href="/details">this link</a>
</div>
 
<!-- ❌ Incorrect: Contains a focusable button -->
<div role="text">
  Submit your form <button type="submit">Submit</button>
</div>

Why It Matters

  • Interactive Visibility: Interactive elements inside role="text" cannot be focused or activated by screen reader users.
  • Semantic Flattening: The entire container is flattened into a single string, losing the semantic meaning of any child elements.
  • User Confusion: Users may see a link visually but find it completely invisible when using a screen reader.
  • Keyboard Access: While a keyboard user might still reach a button inside, the screen reader won't announce it correctly, creating a disconnected experience.

Exceptions

  • Prefer native HTML semantics over ARIA when both are possible; some apparent ARIA failures disappear when the underlying element is corrected.
  • A missing ARIA attribute is not automatically the strongest finding if the control is already semantically broken, unnamed, or keyboard-inaccessible.
  • Do not add ARIA only to satisfy the rule if the feature should instead be implemented with a native element or a simpler interaction pattern.

Standards

  • Align the implementation with WAI-ARIA 1.2 and verify the rendered experience, not only the source code.
  • Align the implementation with MDN: ARIA and verify the rendered experience, not only the source code.

Verification

Automated Checks

  • Inspect the browser accessibility tree or accessibility pane for the relevant element, role, or accessible name.
  • Run an automated accessibility checker such as axe or Lighthouse where applicable.

Manual Checks

  • Test the affected UI with keyboard-only navigation and confirm the rule holds in the rendered experience.
  • Re-test one representative user flow with a screen reader if this rule affects a key interaction.

Use with AI

Copy these prompts to use with your AI assistant, or install the MCP server to use directly from Claude, Cursor, or Windsurf.

Check

Verify implementation

Identify elements with role="text" and verify they do not contain any focusable elements like buttons, links, or inputs.

Fix

Auto-fix issues

Remove role="text" from containers that have interactive children or move the interactive elements outside.

Explain

Learn more

Explain how role="text" overrides the semantics of descendant elements, making interactive components inaccessible to screen reader users.

Review

Code review

Review the rendered markup and interactive states that affect Avoid focusable descendants in role="text" elements. Flag exact elements, roles, labels, focus behavior, or keyboard interactions that violate the rule, and note how to verify the fix with browser accessibility tooling or assistive tech.

Sources

References used to support the guidance in this rule.

Further Reading

Tools and supplementary material for exploring the topic in more depth.

axe DevTools
deque.comTool

Rules that often go hand-in-hand with this one.

Remove focusable elements from aria-hidden containers

Ensures aria-hidden elements do not contain focusable content to avoid "ghost" focus.

Accessibility
Provide accessible names for ARIA command elements

Checks that command elements like buttons and links have accessible names for screen reader support.

Accessibility
Ensure ARIA roles contain required child roles

Elements with certain ARIA roles must contain the required child roles or the widget structure will be broken for assistive technologies.

Accessibility
Provide accessible names for tree items

All elements with role="treeitem" must have a descriptive accessible name so screen reader users can navigate hierarchical tree widgets.

Accessibility

Was this rule helpful?

Your feedback helps improve rule quality. This stays internal for now.

Loading feedback...
0 / 385