Halloween Sale 15% off Ends in See the plans
CSS

Fixes for Windows High Contrast (Forced Colors) Mode

Makes buttons, focus outlines, icons and custom checkboxes stay visible when visitors use Windows High Contrast or another forced-colors mode, where many themes lose borders and icons.

Don’t have WPIDE yet? Install it on your site

Code

@media (forced-colors: active) {
    button,
    .button,
    .wp-block-button__link,
    .wp-element-button,
    input[type="submit"] {
        border: 2px solid ButtonText !important;
    }

    a:focus-visible,
    button:focus-visible,
    input:focus-visible,
    select:focus-visible,
    textarea:focus-visible {
        outline: 3px solid Highlight !important;
        outline-offset: 2px;
    }

    svg {
        forced-color-adjust: auto;
        fill: currentColor;
    }

    .screen-reader-text:focus,
    .skip-link:focus {
        border: 2px solid CanvasText;
    }
}

Notes

Only applies when the visitor's system forces its own colors; nobody else sees a difference.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.