CSS forced-colors Media Feature

Beginner
2 examples
Updated: Nov 2026

Definition and Usage

The forced-colors media feature detects when the user agent overrides author colors with a limited palette (for example Windows High Contrast). Adapt borders and focus styles so content stays clear.

CSS Syntax

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

Feature Values

ValueMeaningTry it
noneColors are not forcedTry it
activeA forced palette is activeTry it

CSS Examples

Stronger borders when forced

example.css
@media (forced-colors: active) {
  .card {
    border: 2px solid ButtonText;
    background: Canvas;
    color: CanvasText;
  }
}
Try It Yourself

Browser Support

forced-colors is a CSS media feature.

✓ Media Queries Level 5

forced-colors

Treat as progressive enhancement.

88% Modern browsers
Google Chrome Recent
Full support
Mozilla Firefox Recent
Full support
Apple Safari Recent
Full support
Microsoft Edge Recent
Full support
forced-colors Growing support

Bottom line: Keep usable default styles outside the query.

Frequently Asked Questions

It reports whether the browser is actively replacing author colors with a restricted system palette.
No. prefers-contrast is a preference. forced-colors means colors are already overridden.
Canvas, CanvasText, ButtonText, LinkText, and Highlight are common choices.
Prefer system colors and keep meaningful borders rather than removing all styling.
Supported in Chromium and Firefox; useful especially on Windows high-contrast setups.

Next: prefers-reduced-data

Continue with prefers-reduced-data.

prefers-reduced-data →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

2 people found this page helpful