Other User Preference Media Features
You'll learn how to detect and respect additional user preferences like contrast levels, transparency, and forced color modes to create truly inclusive designs.
Beyond Dark Mode and Reduced Motion
You've already learned about prefers-color-scheme and prefers-reduced-motion, but browsers expose several more user preference media features that help you adapt to different accessibility needs. These let users control how content appears based on their system settings or assistive technologies.
Three More Preference Features
prefers-contrast
Detects if users have requested higher or lower contrast in their operating system settings. This helps people with visual impairments or those working in challenging lighting conditions.
/* Standard contrast */
button {
background: #007bff;
color: white;
}
/* Increase contrast when requested */
@media (prefers-contrast: more) {
button {
background: #0056b3;
border: 2px solid black;
font-weight: bold;
}
}
prefers-reduced-transparency
Some users find transparency effects disorienting or hard to read. This feature lets you remove or reduce transparent overlays when requested.
.modal-backdrop {
background: rgba(0, 0, 0, 0.5);
}
@media (prefers-reduced-transparency: reduce) {
.modal-backdrop {
background: rgb(0, 0, 0);
}
}
forced-colors
Detects when a user has enabled high contrast mode (like Windows High Contrast). In this mode, the browser replaces your colors with a limited palette.
@media (forced-colors: active) {
.icon {
/* Use borders instead of background colors */
border: 2px solid currentColor;
}
}
Why These Matter
Think of these features as your website listening to users' "accessibility volume knobs." Just as you'd speak louder for someone hard of hearing, these media features let your design adapt to individual needs automatically.
Key Takeaway: Use prefers-contrast, prefers-reduced-transparency, and forced-colors media features to detect and respect user accessibility preferences, making your designs work for everyone.