forced-colors

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Draft
This page is not complete.

The forced-colors CSS media feature is used to detect if the user agent has enabled a forced colors mode where it enforces a user-chosen limited color palette on the page.

Note: This feature is not supported by any user agent and its specifics are subject to change.

Values

none
Forced colors mode is not active; the page’s colors are not being forced into a limited palette.
active
Indicates that forced colors mode is active. The UA will provide the color palette to authors through the CSS system color keywords and, if appropriate, trigger the appropriate value of prefers-color-scheme so that authors can adapt the page.

User preferences

Currently no user agent implements this feature, although various operating systems do support such preferences and if this media query is ever implemented user agents will likely rely on the settings provided by the operating systems.

Examples

Note: No browser currently implements this feature so the following example will not work.

This example has an annoying color palette by default. This example does not take advantage of the colors provided by the user agent.

HTML

<div class="colors">weird color box</div>

CSS

.colors {
  background-color: red;
  color: grey; 
}

@media (forced-colors: active) {
  .colors {
    background-color: white;
    color: black;
  }
}

Result

Specifications

Specification Status Comment
Media Queries Level 5
The definition of 'forced-colors' in that specification.
Editor's Draft Initial definition.

Browser compatibility

No compatibility data found. Please contribute data for "css.at-rules.media.forced-colors" (depth: 1) to the MDN compatibility data repository.

See also

Document Tags and Contributors

Contributors to this page: tehshane, SphinxKnight, bershanskiy
Last updated by: tehshane,