Motion, Focus, and Accessibility
Style visible focus, reduced-motion alternatives, robust states, and accessible contrast.
CSS can support or block access. Keyboard focus needs a visible indicator, information must not depend on color alone, motion should respect user preference, and visually hidden text must remain available to assistive technology.
See the core pattern
Read this rule set from the outside in. Identify the inputs, the decision or transformation, and the result before changing it.
:focus-visible {
outline: 3px solid #718817;
outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
scroll-behavior: auto !important;
animation: none !important;
}
}Working rules
- Test every interactive element with a keyboard
- Keep focus indicators visible against every surface
- Offer a reduced-motion path without removing useful state changes
A common mistake
outline: none removes essential navigation feedback unless an equally visible replacement is provided.
Guided practice
Name the pseudo-class that targets keyboard-like focus without styling every pointer click.
- Copy the example into the editable notebook below.
- Change one thing at a time and keep the program or rule valid.
- Explain the result in one sentence without relying on jargon.