CSS Accessibility and Contrast
Contrast and readability
Choose text and background colors with adequate contrast. WCAG guidance commonly calls for at least 4.5:1 contrast for normal text and 3:1 for large text, subject to the standard’s exceptions.
Visible focus
:focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
Reduced motion
@media (prefers-reduced-motion: reduce) {
html { scroll-behavior: auto; }
*, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
Do not use color as the only signal for errors or status. Add labels, text, icons, or patterns as needed.
Practice
Check a page with a contrast checker and keyboard navigation.
Want to learn this professionally?
Explore practical IT training at Cyber Code Academy.
View Academy Courses