CSS forced-color-adjust Property

The forced-color-adjust property controls whether a browser can replace an element's colors when forced colors mode is active.

Forced colors mode allows users to apply a limited, system-defined color palette for improved readability. By default, browsers adjust many author-defined colors to match the user's chosen palette. The forced-color-adjust property can preserve selected author colors when necessary, but overriding the user's preferences should be limited to cases where color carries essential information.

forced-color-adjust Syntax

The forced-color-adjust property accepts three keywords: auto, none, and preserve-parent-color.

Basic Syntax

selector {
  forced-color-adjust: auto;
}

Preserve Author Colors

selector {
  forced-color-adjust: none;
}

Preserve the Parent's Text Color

selector {
  forced-color-adjust: preserve-parent-color;
}

CSS-Wide Keywords

.example {
  forced-color-adjust: inherit;
}
.example {
  forced-color-adjust: initial;
}
.example {
  forced-color-adjust: unset;
}
.example {
  forced-color-adjust: revert;
}
.example {
  forced-color-adjust: revert-layer;
}

The property primarily affects rendering when forced colors mode is active. In ordinary color rendering, changing this property generally does not produce a visible difference.

Property Values

The property provides the following values.

Value Description
auto Allows the browser to adjust the element's colors according to the active forced color palette.
none Prevents forced color adjustments for the element and its inherited styling context, preserving author-defined colors.
preserve-parent-color Behaves like none but preserves the parent's used text color for an inherited color value.

Property Characteristics

Characteristic Value
Initial value auto
Inherited Yes
Applies to All elements
Computed value As specified
Animation type Discrete
Percentages Not applicable

Because the property is inherited, disabling forced color adjustments on a container can also affect its descendants unless they explicitly restore automatic adjustment.

How It Works

Forced colors mode changes how certain CSS color properties are rendered so that content follows a user-selected color palette.

Normal Rendering

.notice {
  color: #ffffff;
  background-color: #2456a6;
  border: 2px solid #173b75;
}

Under ordinary conditions, the browser uses these author-defined colors.

Forced Colors Rendering

When forced colors mode is active, the browser may replace the text, background, and border colors with values from the user's palette.

Allow Automatic Adjustments

.notice {
  forced-color-adjust: auto;
}

This keeps the element compatible with forced colors mode.

Disable Automatic Adjustments

.notice {
  forced-color-adjust: none;
}

This preserves the author's color choices instead of allowing the normal forced color substitutions.

Important Consideration

Disabling forced color adjustments can make content difficult to read for users who depend on a custom color palette. The default behavior is preferable for most interface elements.

Forced Colors Mode

Forced colors mode is an accessibility feature that restricts colors to a user-selected palette. Windows High Contrast themes are a common example.

What Changes?

Browsers may override colors used for text, backgrounds, borders, outlines, and other visual features.

What Does Not Necessarily Change?

Forced colors mode does not simply convert an entire webpage into grayscale. The selected palette can contain different foreground, background, and accent colors.

Background Images

Browsers may suppress non-URL background images, including CSS gradients, when forced colors mode is active. URL-based background images are handled differently and are not automatically replaced in the same way.

Text Shadows

Text shadows and box shadows are commonly forced to none to prevent them from interfering with readability.

System Color Palette

CSS system colors such as Canvas, CanvasText, ButtonFace, and ButtonText reflect the active user color scheme.

Important Consideration

Forced colors mode is different from dark mode. A dark color scheme does not necessarily indicate that forced colors mode is active.

The auto Value

The auto value allows the browser to apply forced color adjustments. It is the initial value and the recommended choice for most content.

Basic Example

.button {
  forced-color-adjust: auto;
}

Normal Interface Styling

.button {
  color: #ffffff;
  background-color: #2456a6;
  border: 2px solid #2456a6;
  forced-color-adjust: auto;
}

When forced colors mode is active, the browser can replace these colors with appropriate system colors.

Restore Automatic Adjustment

.parent {
  forced-color-adjust: none;
}
.parent .button {
  forced-color-adjust: auto;
}

The child element restores automatic forced color adjustments after inheriting none from its parent.

Typical Uses

Use auto for buttons, forms, navigation, text, cards, and most other interface elements.

Important Consideration

Because auto is the default, explicitly declaring it is usually unnecessary unless overriding an inherited value.

The none Value

The none value prevents the browser from replacing an element's colors with the forced color palette.

Basic Example

.color-sample {
  forced-color-adjust: none;
}

Preserve a Color Swatch

.color-swatch {
  width: 80px;
  height: 80px;
  background-color: #e63946;
  forced-color-adjust: none;
}

This can be appropriate when the exact displayed color is the subject of the content, such as a color picker or palette reference.

Preserve Multiple Swatches

.swatch-red {
  background-color: #e63946;
  forced-color-adjust: none;
}
.swatch-blue {
  background-color: #457b9d;
  forced-color-adjust: none;
}
.swatch-green {
  background-color: #2a9d8f;
  forced-color-adjust: none;
}

Avoid Applying none Globally

body {
  forced-color-adjust: none;
}

This is generally a poor accessibility choice because the property is inherited and can prevent large portions of the page from honoring the user's selected palette.

Important Consideration

Use none only for elements whose original colors are essential to their meaning. Keep surrounding text and controls compatible with forced colors mode.

The preserve-parent-color Value

The preserve-parent-color value disables forced color adjustments while preserving the parent's used text color when the element's color property is inherited.

Basic Example

.icon {
  forced-color-adjust: preserve-parent-color;
}

SVG Icon Example

<button class="icon-button">
  <svg class="button-icon" viewBox="0 0 24 24" aria-hidden="true">
    <path d="M5 12l4 4L19 6" />
  </svg>
  Save Changes
</button>
.icon-button {
  color: #2456a6;
}
.button-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  forced-color-adjust: preserve-parent-color;
}

When the SVG inherits its text color from the button, the icon can follow the button's used color in forced colors mode.

Explicit Color Override

.icon {
  color: #e63946;
  forced-color-adjust: preserve-parent-color;
}

If the element explicitly defines its own color, that color is not inherited from the parent. The special parent-color behavior therefore does not apply in the same way.

Important Consideration

This value is particularly useful for icons that use currentColor and need to remain visually consistent with their parent element.

CSS System Colors

CSS system colors allow elements to use colors associated with the active operating system or browser color palette.

Common System Colors

Color Purpose
Canvas Background color for application content.
CanvasText Text color for application content.
ButtonFace Background color for buttons.
ButtonText Text color for buttons.
Highlight Background color for selected content.
HighlightText Text color for selected content.
LinkText Text color for links.
GrayText Text color for disabled or inactive content.

System Color Example

.system-button {
  color: ButtonText;
  background-color: ButtonFace;
  border: 2px solid ButtonText;
}

Selected Content

.selected-item {
  color: HighlightText;
  background-color: Highlight;
}

Important Consideration

System colors help preserve contrast and consistency with user preferences. They are often preferable to disabling forced color adjustments.

The forced-colors Media Query

The forced-colors media feature detects whether forced colors mode is active.

Detect Forced Colors Mode

@media (forced-colors: active) {
  .button {
    border: 2px solid ButtonText;
  }
}

Normal Color Mode

@media (forced-colors: none) {
  .button {
    background-color: #2456a6;
    color: #ffffff;
  }
}

Adapt a Custom Component

.custom-button {
  color: #ffffff;
  background-color: #2456a6;
  border: 2px solid transparent;
}
@media (forced-colors: active) {
  .custom-button {
    border-color: ButtonText;
  }
}

The forced colors rule gives the button a visible border even when its original background colors are replaced.

Use with forced-color-adjust

@media (forced-colors: active) {
  .color-swatch {
    forced-color-adjust: none;
  }
}

Important Consideration

Use the media query to improve component visibility in forced colors mode. Avoid using it solely to recreate the website's original color scheme.

Preserving Essential Colors

Some interfaces display colors as information rather than decoration. In these cases, preserving the original colors may be necessary.

Color Palette Example

<div class="palette-item">
  <span class="palette-swatch"></span>
  <span>Brand Blue: #2456a6</span>
</div>
.palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
}
.palette-swatch {
  display: inline-block;
  width: 48px;
  height: 48px;
  background-color: #2456a6;
  border: 1px solid CanvasText;
  forced-color-adjust: none;
}

The swatch retains the original blue, while the surrounding text remains available for forced color adjustments.

Color Comparison Tools

Color converters, palette generators, and color selection tools may need to preserve exact swatch colors so users can evaluate them.

Provide Text Labels

Always provide a text label, color value, pattern, or another non-color indicator when color conveys important information.

Important Consideration

Preserving essential colors does not remove the need for accessible labels and sufficient contrast. Color should not be the only way information is communicated.

Borders and Backgrounds

Forced colors mode can change how borders, backgrounds, and decorative effects are displayed.

Transparent Borders

.button {
  border: 2px solid transparent;
}

A transparent border may become visible in forced colors mode because the browser replaces certain border colors with system colors.

Explicit Border in Forced Colors Mode

@media (forced-colors: active) {
  .button {
    border: 2px solid ButtonText;
  }
}

Background Color Replacement

.panel {
  color: #ffffff;
  background-color: #2456a6;
  forced-color-adjust: auto;
}

With automatic adjustment enabled, the browser can replace the panel's colors with appropriate values from the active palette.

Background Gradients

.banner {
  background-image: linear-gradient(90deg, #2456a6, #6c3fa0);
}

Forced colors mode can suppress CSS gradients. Do not rely on a gradient alone to communicate information or distinguish an interactive element.

Box Shadows

.card {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

Box shadows may be removed in forced colors mode. Use visible borders or other indicators when a component boundary is important.

Important Consideration

Design controls and containers so they remain understandable even when decorative backgrounds, gradients, and shadows are unavailable.

SVG and Icons

Icons should remain visible and understandable when forced colors mode is active.

Use currentColor

.icon {
  fill: currentColor;
}

The currentColor keyword allows an icon to use the element's current text color.

SVG Icon Example

<svg class="status-icon" viewBox="0 0 24 24" aria-hidden="true">
  <circle cx="12" cy="12" r="9" />
</svg>
.status-icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

Preserve the Parent Color

.status-icon {
  fill: currentColor;
  forced-color-adjust: preserve-parent-color;
}

Avoid Hard-Coded Icon Colors

.status-icon {
  fill: #2456a6;
}

Hard-coded icon colors may not contrast with the user's forced color palette. Using currentColor is often more reliable.

Important Consideration

Do not disable forced color adjustments on all SVG elements. Preserve specific colors only when their exact appearance is essential.

Accessibility Considerations

Forced colors mode exists to support users who need specific color combinations for readability.

Respect User Preferences

Allow browsers to adjust text, controls, and interface backgrounds whenever possible.

Avoid Global Overrides

* {
  forced-color-adjust: none;
}

This rule can prevent forced color adjustments across the entire page and should be avoided.

Preserve Focus Indicators

.button:focus-visible {
  outline: 2px solid Highlight;
  outline-offset: 3px;
}

A visible focus indicator helps keyboard users identify the currently focused control.

Do Not Rely on Color Alone

Use text, labels, icons, patterns, or borders to communicate states such as success, error, warning, or selection.

Test Forced Colors Mode

Check that text remains readable, controls remain distinguishable, and important information is still visible when forced colors mode is enabled.

Important Consideration

Use forced-color-adjust: none sparingly. Most accessibility problems are better addressed by adapting component styling to system colors rather than disabling the user's palette.

Inheritance

The forced-color-adjust property is inherited. Child elements receive the parent's specified behavior unless they override it.

Inherited Value

.color-preview {
  forced-color-adjust: none;
}
<div class="color-preview">
  <span class="swatch"></span>
  <p>Color preview description</p>
</div>

Both the swatch and the paragraph inherit none unless another value is declared.

Restore Automatic Adjustment

.color-preview {
  forced-color-adjust: none;
}
.color-preview p {
  forced-color-adjust: auto;
}

Explicit Inheritance

.child {
  forced-color-adjust: inherit;
}

Reset to Initial Value

.child {
  forced-color-adjust: initial;
}

Important Consideration

Apply none to the smallest practical element. This reduces the chance of unintentionally disabling forced color adjustments for related content.

forced-color-adjust Example

This example compares a color swatch that preserves its original color with a text panel that allows automatic forced color adjustments.

HTML Example

<div class="forced-color-demo">
  <div class="color-sample">
    <span class="sample-swatch"></span>
    <span>Original Color: #2456a6</span>
  </div>
  <div class="sample-panel">
    This panel follows the active forced color palette.
  </div>
</div>

CSS Example

.forced-color-demo {
  font-family: Arial, sans-serif;
}
.forced-color-demo .color-sample {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.forced-color-demo .sample-swatch {
  display: inline-block;
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  background-color: #2456a6;
  border: 2px solid #173b75;
  forced-color-adjust: none;
}
.forced-color-demo .sample-panel {
  padding: 16px;
  color: #ffffff;
  background-color: #2456a6;
  border: 2px solid #173b75;
  forced-color-adjust: auto;
}
Browser Result
Original Color: #2456a6
This panel follows the active forced color palette.

In normal color mode, both areas use the specified blue. When forced colors mode is active, the swatch retains its original color while the panel can adopt colors from the user's selected palette.

To observe the difference, enable a forced colors theme in a supported operating system and browser. The example does not simulate forced colors mode automatically.

Common Mistakes

Common mistakes involve disabling accessibility adjustments unnecessarily or misunderstanding how the property works.

Using an Invalid Value

.example {
  forced-color-adjust: disabled;
}

The disabled keyword is invalid. Use none to prevent forced color adjustments.

Using a Boolean Value

.example {
  forced-color-adjust: false;
}

The property does not accept Boolean values.

Disabling Forced Colors Globally

body {
  forced-color-adjust: none;
}

This can prevent the user's color preferences from being applied throughout the page.

Confusing Forced Colors with Dark Mode

Forced colors mode and dark mode are different features. Use the forced-colors media query to detect forced colors mode.

Assuming none Improves Contrast

Preserving author colors does not guarantee sufficient contrast. The original colors may be difficult to read against the user's preferred background.

Relying on Color Alone

Color-coded indicators should also include text labels, patterns, or another way to identify their meaning.

Forgetting Inheritance

The property is inherited, so applying none to a parent can affect descendants unexpectedly.

Ignoring Icon Contrast

Hard-coded SVG colors may become difficult to see in forced colors mode. Prefer currentColor when appropriate.

Testing Only in Normal Mode

The property's effects may not be visible until forced colors mode is enabled.

Important Considerations

Keep the following points in mind when using the forced-color-adjust property:

  • Purpose: Controls automatic color adjustments in forced colors mode.
  • Initial value: auto.
  • Inheritance: The property is inherited.
  • Applies to: All elements.
  • auto: Allows the browser to use the forced color palette.
  • none: Prevents forced color adjustments for the element.
  • preserve-parent-color: Preserves the parent's used text color when color is inherited.
  • Default behavior: Most interface elements should retain auto.
  • Essential colors: Preserve exact colors only when they are necessary to understand the content.
  • System colors: Use values such as CanvasText, ButtonText, and Highlight for compatible styling.
  • Media queries: Use @media (forced-colors: active) to adapt components.
  • Backgrounds: Author-defined backgrounds and gradients may be replaced or suppressed.
  • Shadows: Decorative shadows may be removed.
  • SVG icons: currentColor can help icons follow the active text color.
  • Contrast: Preserving colors does not guarantee readable contrast.
  • Color-only information: Provide text or another non-color indicator.
  • Scope: Apply none to the smallest practical element.
  • Testing: Test with an actual forced colors theme.
  • Animation: Values change discretely rather than interpolating.
  • Browser support: Core functionality is widely supported in modern browsers, while support for individual values can vary.

Use forced-color-adjust to preserve essential color information without overriding accessibility preferences for the rest of the interface. For ordinary content, the default auto value is usually the best choice.

Browser Support

The CSS forced-color-adjust property has Widely available support in modern browsers, including Chrome, Edge, Firefox, and Safari.

Support for the newer preserve-parent-color value may differ from support for the established auto and none values.

Basic Example

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

Forced Colors Detection

@media (forced-colors: active) {
  .color-swatch {
    forced-color-adjust: none;
  }
}

Testing

The property should be tested with forced colors mode enabled. Browser support alone does not guarantee that a user's operating system has forced colors mode active.

For current compatibility information, visit Can I Use? and search for forced-color-adjust.

Specifications

The forced-color-adjust property is defined in the CSS Color Adjustment Module, which describes forced colors mode and related color adjustment behavior.

CSS Color Adjustment Module Level 1: forced-color-adjust

The specification also defines the forced-colors media feature and how user-selected palettes affect CSS color rendering.

CSS Color Adjustment Module Level 1

For additional explanations and examples, see MDN Web Docs.

MDN Web Docs: forced-color-adjust