Responsive layout

responsive/no-hover-only

Nothing is revealed on hover alone; content and controls shown on hover also show on keyboard focus and are reachable on touch.

seriousstaticWCAG 2.1.1 · Afe-responsive

Why

Touch screens have no hover, and keyboard users never hover. Edit buttons, submenus or details that appear only under the mouse are missing for them, or appear only by accident on a tap.

Fix

Reveal the same content on :focus-within of the container (or :focus-visible of the trigger), and on touch show it by default or behind a button. With Tailwind, pair group-hover: with group-focus-within:. A menu that opens on hover also needs a button that opens it, and content that appears must stay until dismissed (Escape).

Examples

/* bad */
.card:hover .card__actions { display: flex; }
/* good */
.card:hover .card__actions,
.card:focus-within .card__actions { display: flex; }

Sources

Facts

Id
responsive/no-hover-only
Severity
serious
Check
static checked in the source by audit
Applies to
css scss less html vue svelte astro jsx angular
WCAG 2.2
2.1.1, level A
Taught by the skill
fe-responsive Responsive design
Since version
0.1.0

Rule file on GitHub

Read it in the terminal

npx github:dawidolko/frontend-skills explain responsive/no-hover-only