Forced colors

What it is

Forced colors is a mode in which the user agent applies a restricted
colour palette chosen for the user's needs. It can override some
colours supplied by a page so text, surfaces and controls use the
platform's selected colours. In CSS, a `(forced-colors: active)`
media query lets authors make targeted adjustments when the browser
applies this palette.

The browser chooses system colours based on the element and
property. A page can also use system colour keywords to describe the
role it needs, such as `CanvasText` for text on the page canvas or
`ButtonText` for the foreground of a button. Several forms of
decorative paint can be reduced or removed. Check which parts of a
component carried meaning and make sure those parts remain
distinguishable under the selected conditions.

The `forced-color-adjust` property lets authors opt out of automatic
colour adjustment for particular elements. That creates a
responsibility to keep those elements readable in the actual user
palette. Use an opt-out narrowly where the content requires it and
test it with meaningful colour choices. Native control semantics and
alternative states matter as much as pixel appearance in this mode.

Why it matters

A design can rely on a subtle shadow or a tinted surface to describe
where an action begins and ends. When the browser changes those
colours, the label can remain readable while the button loses its
visible boundary. A list can use fill colours to mark which item is
selected, and all items can appear similar after automatic
adjustment. The user still needs a way to recognise the action and
its state.

Forced-colour users can have different chosen palettes. A team
should test more than one representative setting, including dark and
light system colours where the environment supports them. A fix that
manually declares a white stroke might look clear in one palette and
vanish in another. The useful distinction is usually the role of the
stroke or text, which a system keyword can help express.

Common interaction feedback also needs attention. Focus, selection,
disabled state and an error signal should remain understandable.
Shapes, labels and outlines can provide redundant evidence where
colour changes. Begin with the task the user needs to perform and
preserve the parts of visual hierarchy that guide it.

What it looks like in practice

Imagine a menu with a selected item and a button that opens it. Load
it with forced colours active and use the keyboard to reach the
button. Look for a visible boundary and focus indicator. Open the
menu and look at the current selection, an unavailable item and the
next focus target. Check what state the browser exposes as well as
what the user can see.

Review the properties that paint each part. A shadow may have made
the surface visible in the ordinary design. A border using an
appropriate system colour can make its edge visible in forced
colours. An icon that follows the element's text colour can continue
to match the surrounding control. Test its meaning with its
accessible name or label and check that it remains distinguishable
against the button's background.

Engineer's site accessibility statement documents checks for visible
focus, names, contrast and the scope of its rendered evaluations.
Those are useful starting points for a forced-colour exercise. The
illustrative menu test keeps the same action, names and order and
adds observation with the user's restricted palette. The result
should say which component state and platform setting produced the
evidence.

Include text placed over a decorative background. The browser's
adjustments can change the relationship between that text and the
image or surface behind it. Check the complete result after the
preference applies. A design can preserve the intended reading order
and use an explicit background where the page's original colours no
longer provide the needed distinction.

Where it goes wrong

A common mistake is to tune only ordinary light and dark themes.
Forced colours changes paint according to the user's system palette
and browser rules. Inspect the painted state while the system
palette is active. Check important controls and boundaries under the
preference independently of the choices made for other colour
schemes.

Another issue is undoing the browser's adjustments across a large
region. A fixed palette can reduce readability for the person who
selected the mode. Choose the smallest element that needs special
handling and exercise it with the relevant palettes. Keep ordinary
controls aligned with the system roles where they can use them.

Native semantics can influence which role colours the browser
chooses. A custom element that looks like a button may be painted
according to different defaults from a native button. Compare actual
browser output for text, fill and border when reviewing a custom
control. Preserve its role and name when adapting its visual
treatment, so the same interaction remains identifiable.

An automated browser can exercise a forced-colour preference and
reveal missing boundaries quickly. A check on an actual platform
palette can add evidence about a user's chosen colours and system
controls. Name which conditions were exercised. Re-test ordinary and
forced palettes after changing a shared component so a narrow fix
stays attached to the state that needed it.

Finally, track meaning that used to depend on a fill, gradient or
shadow. A selected item can gain a clear indicator. A text label can
make a status understandable even if the system palette changes its
colour. Check long labels and constrained layouts as well as a clean
sample. The feature works when the user can identify the element,
understand its state and complete the same task through the adjusted
design.

Further reading

  * W3C CSS Color Adjustment forced colours. Specifies the user
agent's adjustment model.

  * W3C Media Queries forced-colors feature. Defines how authors
detect the active state.

  * Mozilla's forced-colors documentation. Gives authoring examples
and notes on affected properties.

hThis page on the web	URL:https://engineer.company/glossary/forced-colors/	engineer.company	70
