Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Colors and Backgrounds

The forced-color-adjust property

Reference for the CSS forced-color-adjust property: when to opt an element out of forced colors mode, why it is risky, and how to keep text readable.

Some users switch on forced colors mode (for example Windows contrast themes) to get a small, high-contrast palette on every site. The browser then overrides many of your colors with system colors. The forced-color-adjust property lets an element say whether the browser may do that.

By default (auto) the override happens, and that is almost always what you want. Use none only for content whose colors carry meaning that would be lost, such as a color swatch in a picker, and then make sure the result stays readable.

CSS
.swatch {
  forced-color-adjust: none;
}

Try it

A swatch that keeps its color

You will only see a difference if forced colors mode is active on your device. The status line uses the forced-colors media feature to tell you.

Syntax

CSS
forced-color-adjust: auto | none | preserve-parent-color
  • Initial value: auto
  • Applies to: all elements and text
  • Inherited: yes
  • Animatable: no
  • Computed value: as specified

Values

Value Description
auto The browser may replace colors with the forced palette. This is the default and the recommended choice.
none The element keeps the colors you specified. Properties that forced colors would normally override are left alone.
preserve-parent-color Like none for the element's text, but color is kept equal to the parent's forced color so text stays consistent with its surroundings. Useful for an element, such as an SVG icon, that uses currentcolor.

Usage notes

  • Treat none as a last resort. Forced colors exist for people with low vision, light sensitivity or other needs. Overriding them can make your content unreadable for exactly those people.
  • If you opt out, take responsibility for contrast. Pair the element with system colors (Canvas, CanvasText, LinkText, ButtonText) for borders and text, as the swatches do, so the surrounding text still passes.
  • Good candidates: color pickers, charts and legends where color is the data, and images drawn with CSS backgrounds that must keep their look.
  • Bad candidates: whole pages, navigation, buttons and body text.
  • It inherits, so setting it on a container affects everything inside. Scope it tightly to the specific element.
  • Test it. Turn on a contrast theme in your operating system or use your browser's developer tools to emulate forced colors.
  • Prefer forced-colors queries for adjustments. Inside @media (forced-colors: active) you can add a visible border to a control that relied on a background color alone.

Browser support

Supported in Chromium-based browsers, Firefox and Safari in current versions; check a compatibility table for the exact releases and for preserve-parent-color, which is less widely implemented.