Skip to content

Commit

Permalink
Fix mark styles in Windows High Contrast Mode
Browse files Browse the repository at this point in the history
In some browsers (IE11, Chromium-based browsers) the marked text in
search results are unreadable with forced colour modes when the
background is black because the text colour for `<mark>` elements is
set to black.

This commit fixes this by re-asserting that the marked text should
be the same colour as the surrounding text.

We also have to set `background-color: Canvas`, because in Firefox
`background-color: transparent` is also ignored (unlike in IE11,
Chromiums).
  • Loading branch information
lfdebrux committed Sep 24, 2021
1 parent dc6cf3f commit 89a92a8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/assets/stylesheets/modules/_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,20 @@ html.has-search-results-open {
background-color: transparent;
color: inherit;
font-weight: bold;

// In forced color mode some browsers will keep the background transparent
// but set the text colour black, making the highlighted text unreadable.
// The following blocks fix this by setting the text colour to be the same as
// other text in a way that forced color mode will respect.

@media screen and (-ms-high-contrast: active) {
// IE does not support `CanvasText`,
// and `currentColor` does not work with Blink
color: currentColor;
}

@media screen and (forced-colors: active) {
background-color: Canvas; // needed for Firefox
color: CanvasText;
}
}

0 comments on commit 89a92a8

Please sign in to comment.