Forced colors mode lets a browser replace authored colors with a small user-selected palette, most often for high-contrast accessibility settings. Supporting it with CSS keeps content, controls, focus rings, and selected states visible when decorative color choices are no longer in charge.
The safest forced-colors branch is small. Let the browser adjust ordinary text and native controls, then use system color keywords such as Canvas, CanvasText, ButtonText, and Highlight for custom borders and focus indicators. Shadows disappear in forced colors, so a shadow alone cannot define a control or its focus state.
Selection also needs meaning beyond color, such as a visible text label. Chrome DevTools can emulate forced colors while a page is open, but the palette can differ from a user's Windows contrast theme. Leaving forced-color-adjust at its default lets the browser honor that palette; setting it to none can make text unreadable.
Steps to support forced colors mode with CSS:
- Create a file named index.html in your text editor with a native button and a text label for the selected plan.
- index.html
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Account plan</title> <link rel="stylesheet" href="styles.css"> </head> <body> <main class="panel"> <h1>Account plan</h1> <p class="status">Selected plan: Personal</p> <button class="action" type="button">Save changes</button> </main> </body> </html>
The label keeps the selected plan understandable when its green background disappears. A native button also receives the browser's button-specific system colors.
- Create styles.css in the same folder with the normal colors, borders, and keyboard focus outline.
- styles.css
body { margin: 2rem; font: 1.125rem/1.5 system-ui, sans-serif; background: #f8fafc; color: #111827; } .panel { max-width: 28rem; padding: 1.5rem; border: 1px solid #cbd5e1; background: white; box-shadow: 0 0.5rem 1.5rem #0002; } h1 { margin-top: 0; } .status { padding: 0.5rem; border: 2px solid #166534; background: #dcfce7; color: #166534; } .action { padding: 0.6rem 1rem; font: inherit; border: 2px solid transparent; background: #2563eb; color: white; } .action:focus-visible { outline: 3px solid #c2410c; outline-offset: 4px; }
The transparent button border reserves space for a visible border in forced colors without changing the button's size.
- Append the forced-colors overrides at the end of styles.css.
- styles.css
@media (forced-colors: active) { .panel { border-color: CanvasText; } .status { background: Canvas; color: CanvasText; border-color: Highlight; } .action { background: ButtonFace; color: ButtonText; border-color: ButtonText; } .action:focus-visible { outline-color: Highlight; } }
Canvas and CanvasText follow the page surface and text colors. ButtonFace and ButtonText follow button colors, while Highlight supplies the selection border and focus outline. The browser suppresses the panel's shadow automatically.
- Save both files in the same folder.
- Open the saved index.html file in Chrome using its local file address.
The address starts with file:/// and points to the folder containing your files. A web server is unnecessary for this HTML and CSS.
- Open Chrome DevTools with F12.
Before emulation, the page has a blue button and a green selected-plan label.
- Open the DevTools Command Menu with Ctrl+Shift+P.
On macOS, the shortcut is Command+Shift+P.
- Run Show Rendering from the Command Menu.

- Choose forced-colors: active under Emulate CSS media feature forced-colors in Rendering.
The control is farther down the scrollable Rendering panel. Emulation applies immediately and remains active while DevTools is open.
- Click the Account plan heading to return keyboard input to the page.
The authored green background is now replaced by the emulated palette. The DevTools divider can be dragged downward if it hides the button.
- Focus Save changes with the Tab key.

- Confirm the button has a visible focus outline and border alongside the readable selected-plan label.
The label's border and text remain visible without the green background, and the panel no longer has a shadow. Exact colors depend on the active palette; a missing outline, disappearing button edge, or unreadable label indicates that the styles still need attention.