Skip to content

Instantly share code, notes, and snippets.

@captainbrosset
Last active April 29, 2024 09:33
Show Gist options
  • Save captainbrosset/cfb9fe93005d9c25437af2c3a8954ef0 to your computer and use it in GitHub Desktop.
Save captainbrosset/cfb9fe93005d9c25437af2c3a8954ef0 to your computer and use it in GitHub Desktop.
Backward compatible high-contrast/forced-colors mode
@media (-ms-high-contrast: active), (forced-colors: active) {
/* Your general contrast theme styles */
}
@media (-ms-high-contrast: black-on-white), (forced-colors: active) and (prefers-color-scheme: light) {
/* Your specific light contrast theme styles */
}
@media (-ms-high-contrast: white-on-black), (forced-colors: active) and (prefers-color-scheme: dark) {
/* Your specific dark contrast theme styles */
}
/* For elements that need to opt-out of contrast theme styles */
.opt-out-of-high-contrast {
-ms-high-contrast-adjust: none;
forced-color-adjust: none
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment