Bird
0
0

Find the accessibility issue in this Angular template snippet:

medium📝 Debug Q7 of 15
Angular - Internationalization and Accessibility
Find the accessibility issue in this Angular template snippet:
<div role="button" (click)="doAction()">Click me</div>
AThe div should not contain text.
BMissing keyboard event handlers for accessibility.
CThe click event should be replaced with a submit event.
Drole="button" is invalid on div elements.
Step-by-Step Solution
Solution:
  1. Step 1: Understand role="button" usage

    Assigning role="button" to a div makes it behave like a button for screen readers.
  2. Step 2: Check for keyboard accessibility

    Without keyboard event handlers (like keydown for Enter/Space), keyboard users cannot activate it.
  3. Final Answer:

    Missing keyboard event handlers for accessibility. -> Option B
  4. Quick Check:

    role=button needs keyboard handlers [OK]
Quick Trick: Add keyboard handlers when using role="button" on div [OK]
Common Mistakes:
  • Thinking role="button" is invalid on div
  • Replacing click with submit incorrectly
  • Believing div cannot have text

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes