High contrast mode is a special rendering mode on Windows that applies forced colors and simplifies visual elements throughout the entire platform. This mode is an accessibility feature of Windows and used by people with low vision or visual acuity issues. High contrast mode severally changes the way that websites are rendered on all Windows browsers.
References
- Enabling high contrast and customizing it (Windows 10 & 11)
- Styling Edge for Windows high contrast mode
forced-colors
media query (Modern browser support)-ms-high-contrast
media query (IE11 and Legacy Edge support)- forced-colors W3C standards
Default | HC Chromium | HC Firefox |
---|---|---|
Chromium-based browsers (Edge and Chrome) and Firefox both respect the forced color and style adjustments of Windows in high contrast mode. Both browsers types use the system colors rather than user specified colors for most elements. The deprecated -ms-high-contrast
query still works on Edge, but is expected to be removed "soon". The system colors names and specification is often seen as deprecated as well, but that is the recommended way to specify a color and have it work in high contrast mode. Canvas
and CanvasText
are meant to replace Window
and WindowText
and are currently supported in both browser types on Windows. Other than that difference the MDN article on -ms-high-contrast
linked above has the other system color names that one can use.
While both browser types render high contrast, there are some obvious differences between the browsers. The most obvious difference is in rendering SVGs with a fill
of currentColor
. Chromium on Windows has a specific user-agent style for SVG that sets forced-color-adjust: none
. This allows one to easily set the color on an SVG in those browsers. However, there is no guaranty that the SVG will have appropriate contrast or even be visible. On Firefox, SVG's currentColor is forced to the WindowText/CanvasText color. This ensures that the icon is visible, but eliminates any color information that the SVG is expected to convey. Another, less obvious difference is that Chromium also sets the value of the prefers-color-scheme
in high contrast mode depending on the Window/Canvas color used by the high contrast theme. High contrast themes with backgrounds below a certain luminosity get prefers-color-scheme: dark
while background values above that threshold get prefers-color-scheme: light
set, regardless of other system preferences. This is not the case in Firefox, which follows the system preference and defaults to prefers-color-scheme: light
regardless of the actual theme colors. Because of the way that Firefox overwrites SVG currentColor
along with the other rendering changes, the value of prefers-color-scheme
has little impact on what the user sees. In Chromium, the primary difference is also in SVG's. Since they maintain the CSS specified color for currentColor
, if there are different color values depending on the prefers-color-scheme
value then they are seen by the user.
The most notable changes with high contrast mode are that box-shadow and background-color compute to none
. This means that any component attempting to show state or other information using either of these properties will not show properly if at all. An obvious example of this is the calcite-switch
component. It provides no obvious information about its checked state in high contrast. The difference in the way that SVG's are rendered causes issues with the calcite-checkbox
component on Firefox and the "neutral" colored buttons with symbols on Chromium browsers.