The CSS forced-color-adjust property controls whether a webpage should respect or override the userβs **forced color mode** (such as Windows High Contrast Mode). It determines if your styles should be replaced by system-enforced colors for accessibility.
Note
β Helps your UI adapt correctly in high-contrast modes
β Should be used carefully β accessibility should remain a priority
π¦ Syntax
Syntax
forced-color-adjust: auto | none;
/* Examples */
forced-color-adjust: auto; /* allow system color adjustments */
forced-color-adjust: none; /* opt out of forced colors */| Value | Description |
|---|---|
| auto | The element adapts to forced-color mode (default) |
| none | Prevents system from overriding your colors |
π¨ Understanding High Contrast / Forced Colors Mode
Operating systems (like Windows) provide a **Forced Colors Mode** where colors become extremely high contrast for users with low vision. The browser replaces standard colors with system-defined ones (e.g., white text on black background).
Note
π¨ 1. Default Behavior (auto)
auto
.button {
background: #ff4757;
color: white;
forced-color-adjust: auto; /* let system adjust */
}If a user enables high-contrast mode, the button will be recolored based on system rules.
π¨ 2. Prevent Forced Colors (none)
none
.logo {
forced-color-adjust: none;
}The logo keeps its original color even in forced-color mode β useful when contrast rules would distort branding.
Note
π¨ 3. Use inside forced-colors media query
forced-colors media
@media (forced-colors: active) {
.card {
border: 2px solid ButtonText;
forced-color-adjust: none;
}
}Allows you to selectively disable or style elements specifically for high-contrast mode.
π¨ 4. Example: Prevent Icons From Being Recolored
icon control
.icon {
forced-color-adjust: none;
fill: currentColor;
}Prevents icons (SVGs) from being automatically recolored by forced-color mode.
π¨ 5. Example: Maintain Brand Colors
brand colors
.brand-header {
forced-color-adjust: none;
background: #000;
color: #fff;
}Useful when certain UI elements must match brand identity.
π§ͺ Real-World Use Cases
1οΈβ£ Keep Brand Logos Visible
logo
img.logo {
forced-color-adjust: none;
}Ensures logos retain original colors.
2οΈβ£ Preserve Syntax Highlighting in Code Blocks
code block
pre code {
forced-color-adjust: none;
}Keeps code highlighting accurate in forced-color mode.
3οΈβ£ Allow High-Contrast Mode to Improve Buttons
accessible button
button {
forced-color-adjust: auto;
}Buttons adopt system high-contrast styling β better accessibility.
β οΈ Common Mistakes
- β Using none everywhere β breaks accessibility
- β Preventing forced colors for text β unreadable in contrast mode
- β Not testing UI in forced-colors mode
- β Overusing forced-color-adjust on decorative elements
Note
π₯ Summary
forced-color-adjust is a crucial accessibility-aware feature that determines whether system-level high-contrast colors will override your styles.
- auto β adapt to system colors (recommended)
- none β prevent system adjustments (use rarely)