To get us all on the same page, forced colors mode is a state the browser or operating system can be put into to force the user’s choice of colours onto the page. It does this by resetting all the site’s stated colours back to system colours, then setting the system colours to match the user’s choice. This has the effect of allowing people who need specific contrast levels both high and low to use your site without discomfort.
There are plenty of great articles on this somewhat overlooked accessibility feature, and they have lots of recommendations on how to fix any problems you find with your site. So rather than repeat them, today we’re going to look at ways to enable forced colors mode to test your site, and how you can ensure in the longer term that you don’t have unexpected regressions.
Test on Windows
If you’re using Windows then the entire OS has support for forced colours. In Windows 11 this functionality is called “Contrast themes”. In Windows 10 and earlier it’s called “High contrast themes”, and it’s been around for a very long time with some form of support going all the way back to Windows 95. You can turn on contrast themes by opening Settings, then going to “Accessibility” and picking the “Contrast themes” option. Once there you can pick from one of the four predefined themes, or edit one to match your preferred colours.

When a contrast theme has been enabled, the entire system will switch the new design. Chromium browsers (for example Chrome, Edge, or Vivaldi) and Firefox will automatically detect this, and render the content of the site in forced colors mode as well, with the colour choices matching that of the operating system’s chosen theme. You can switch the contrast theme off again from Settings, but if you want to quickly switch between your contrast theme and the default display you can use the left Alt + left Shift + Print screen keyboard combination.

A quick note: in forced colors mode we’re not bothered about the specific colours a user has picked, we just want to make sure that our sites work well regardless of the colours the user wants. This is similar to the philosophy behind responsive design: we want our sites to work well regardless of the screen dimensions our users have.
Browser-level support
For people not on Windows, there’s little support for whole-system contrast themes. MacOS and iOS have an “Increase contrast” mode (in the “Display” panel of the “Accessibility” section of Settings) but this doesn’t allow users to pick their own colours: it just increases the contrast of the operating system and exposes this user choice to the web as the prefers-contrast media feature. Android offers just a slight increase in the default colour contrast, and Android browsers typically don’t expose that on the web. Various Linux desktop environments have theming options along with “high contrast” toggles, but on the web – as per Apple systems – these at best trigger prefers-contrast and don’t put the system into forced colors mode.
Luckily all is not lost: there are a couple of browser-based options for us to use.
Firefox has had support for custom colour overrides since before it was Firefox, and these are now hooked up to forced colors mode. From Firefox settings, you can go to the Accessibility section, and set “Web site contrast” to “Custom”, then pick custom colours if you’d like: this will trigger forced colours mode in websites.


This is designed to be a user-facing feature, and it’s handy if you need it and you’re using a system that doesn’t have a system-wide forced colors mode. Once you’ve enabled your override colors then they’ll apply to the sites that you’re using, and the browser will expose the forced-colors: active media query to the site.
Chrome (and other Chromium browsers like Edge) also have a forced colors mode, though unlike the Firefox or Windows implementations it’s aimed squarely at developers. To access it, open Developer Tools on the site you want to test, go to the “Rendering” tab (this might be behind the “+” button in the tab bar), and scroll down to “Emulate CSS media feature forced-colors”. If you set this to “active” then the site will display in forced colors mode. You don’t get any choice of colours here, but as we just want to test the site in this state that’s OK.

Again, enabling this will enable the forced-colors: active media query in the browser, so your site can start reacting to that if necessary. To disable you can either set it back to default, or just close developer tools; this isn’t meant to be a user facing feature but something for developers to test with.
Unfortunately if you’re using Safari you’re out of luck: there’s no support for emulating forced colors mode. This has been discussed on WebKit’s GitHub repository, but ultimately it was decided that until platforms that WebKit runs on (primarily Apple platforms) support forced colors mode there’s no point in supporting its emulation.
Automated checking for forced color regressions
So far we’ve only talked about manual testing, which will help you fix problems that are already in production. We, however, would like accessibility problems to be caught and fixed before they hit production so that users never see them. This approach is often called shift-left testing.
While we could rely on enforced manual testing your site in forced color mode before every deploy, realistically it’s difficult to guarantee this, especially if you’re part of a larger team with lots of contributors to the code. The best thing to stop regressions would be some sort of automated test for forced colors problems, running before each code merge or deploy. Luckily this sort of testing exists already: testing for problems introduced into the rendered view of the site is called visual regression testing.
Let’s go through how you might accomplish this with a commonly used tool.
It’s entirely possible you’re already using Playwright: it’s great for both integration testing and visual regression testing. To set up a visual regression test, you’d script Playwright to start a browser (Chromium by default, though Firefox and WebKit are supported), visit the page you want to test, take a screenshot of the rendered view, then compare it to a previous screenshot of a known-good state to make sure that there aren’t unexpected differences. If there are any differences, you can update the saved screenshot if they’re expected, or fix the bugs if not. A standard visual regression test would look something like:
test('My page renders OK', async ({ page }) => {
await page.goto('/my_page');
const screenshot = await page.screenshot({ fullPage: true });
expect(screenshot).toMatchSnapshot('my_page.png');
});
While a typical product team would already notice changes in the way a site visually renders on default settings, it’s less likely for them to notice regressions in the rendering when the page is in forced colors mode. So let’s set Playwright up to check for that. We can use the same approach but add a new test specifically for forced colors mode, and make sure the browser instance is rendering using forced colours by using page.emulateMedia({ forced-color: active }):
test('My page renders OK in forced colors mode', async ({ page }) => {
await page.goto('/my_page');
await page.emulateMedia({ forced-color: active });
const screenshot = await page.screenshot({ fullPage: true });
expect(screenshot).toMatchSnapshot('my_page_in_forced_colors_mode.png');
});
This creates a separate test for the same page, but this time with a known-good screenshot of what the page in forced colors mode should look like. Any regressions, and the test will fail and throw up a warning for the developer to investigate. If the change is OK, for example if you’ve intentionally changed a part of the page and the forced colors mode rendering of that is fine, then you can run your Playwright tests again with the --update-snapshots flag to copy the new verified-good screenshots over the top of the old ones.
I’ve found that this approach is pretty useful in most places, but it really comes into its own when you’re testing a design system where regressions can easily propagate out to every part of the site.
The only major caveat with this approach is that it doesn’t have WebKit support (due to the aforementioned lack of support for forced color) so if you’re using that for your default Playwright device you’ll want to consider adding a Chromium or Firefox device specifically for forced colour testing.
If you’re using other visual regression testing tools than Playwright then unfortunately, to the best of my knowledge, you’re currently out of luck. Puppeteer has an emulateMediaFeatures function but seemingly no support for forced colors mode: there’s an open issue for this functionality but no recent progress. And both Selenium and Backstop don’t seem to support passing media features through to the browser instance.
Next steps
As I said earlier, there are a bunch of great articles on forced colors mode that will help you fix any problems you find with your site. I’d recommend starting with Curtis Wilcox’s A Deep Dive into Contrast Themes and MDN’s forced-colors documentation. I’d also be remiss not to include a link to my own article on forced colors mode where I detail some of the problems I found and fixed in a large-scale production setting.
Running a simple manual forced colors mode check is an easy thing to do on your site or app, and if you haven’t checked before you’ll likely find a few things you could improve for not much effort. And if this has inspired you to try out adding some form of visual regression testing then I’m sure it’ll pay dividends.