- Success Criterion 2.1.1
- Conformance level A
- W3C reference F55
Element That Loses Focus the Instant It’s Reached by Keyboard
2.1.1 — Keyboard
Scenario
Setting
A car-rental site's checkout flow
What’s wrong
As soon as an element receives keyboard focus, a script throws focus away (blur) — keyboard users can never actually reach or use it.
Example
const carThumbs = document.querySelectorAll('.car-thumb');
carThumbs.forEach(thumb => {
thumb.addEventListener('focus', () => {
thumb.blur(); // added to suppress the default focus outline
});
}); Why it matters
A renter tabbing toward the "Select this car" thumbnail gets bounced away before they can press Enter, so they can never choose a vehicle.
How to test
Tab to any element and check whether it loses focus immediately (blur() firing on focus): if so, you can never interact with it via keyboard.
How to fix
Style away a default outline with CSS if it clashes with the design, never call blur() to hide it.
const carThumbs = document.querySelectorAll('.car-thumb');
carThumbs.forEach(thumb => {
thumb.classList.add('custom-focus-style');
});
/* .custom-focus-style:focus-visible { outline: 3px solid #1a5fb4; } */ Outcome
A renter tabs to a car thumbnail, sees a clear focus ring, and presses Enter to select it.
Who is affected
Keyboard-only users and switch users who tab sequentially can never stay on the control long enough to activate it.
Learn more
- Understanding Understanding document (opens in a new tab)
- Technique Related technique (opens in a new tab)
Related scenarios
- Feature That Only Responds to Mouse Events, Not the Keyboard
- Clickable Element Acting Like a Link With No Real Keyboard Role
- Clickable Div With No Keyboard Focus or Key Handling at All
- Focusable Element That Enter and Space Don’t Actually Activate
- Custom Dropdown That Can’t Be Operated by Keyboard Arrows
- Drag-and-Drop Feature With No Keyboard Alternative