+ All Categories
Home > Documents > Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge...

Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge...

Date post: 24-Aug-2020
Category:
Upload: others
View: 4 times
Download: 0 times
Share this document with a friend
60
Tailoring the High Contrast Experience @soMelanieSaid at TPAC 2019 Web Developer Meetup
Transcript
Page 1: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Tailoring the High Contrast Experience

@soMelanieSaid at TPAC 2019 Web Developer Meetup

Page 2: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 3: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 4: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

“The text on the blue background is kind

of hard to read”

Page 5: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

“The text on the blue background is kind

of hard to read”

Contrast ratio:

1.74:1

Page 6: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

“The text on the blue background is kind

of hard to read”

Contrast ratio:

21:1

Page 7: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

“That’s much better!”

Contrast ratio:

21:1

Page 8: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 9: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Layered Approach Towards Inclusive Color and Contrast

Page 10: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

We can tailor our websites to users’ visual needs.

Page 11: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 12: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 13: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 14: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 15: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 16: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 17: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 18: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

prefers-color-scheme

prefers-contrast

forced-colors

Page 19: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

prefers-color-schemeHint to provide a particular color

scheme (e.g. dark)

Page 20: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 21: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

@media (prefers-color-scheme: dark) {/* “Dark mode” styles */

}

Page 22: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

prefers-contrast Hint to increase or

decrease contrast

Page 23: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

forced-colorsHint that content is rendered in user’s

system colors

Page 24: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

prefers-color-scheme

prefers-contrast

Expectation:the website will fully manage its

own color scheme and contrast

Page 25: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

forced-colors

Expectation:colors are applied

by the browser; the website may want

to optimize its design

Page 26: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 27: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 28: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 29: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

How browsers apply forced colors to web content

Page 30: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 31: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 32: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 33: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 34: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 35: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Reverted properties

color

fill

stroke

text-decoration-color

text-emphasis-color

background-color

border-color

outline-color

column-rule-color

scrollbar-color

-webkit-tap-highlight-color

box-shadow

text-shadow

background-image (only on user interactive controls, excluding buttons)

Page 36: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Why not globally revert background-image?

Many developers use this property to display “content” images

Page 37: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Text backplates guarantee legibility

Page 38: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Color schemes in forced color modes

prefers-color-schemeevaluates appropriately based on Canvas color (page background)

Page 39: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Web devs can apply content-specific knowledge to tailor

the forced colors experience.

Page 40: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

SVGs are not modified…mostly

Only SVG <text> and<foreignObject> have forced colors applied for legibility

Page 41: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

currentColor

.header__brand-icon * {stroke:currentColor;

}

.header__c-glyph {fill: currentColor;

}

Page 42: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Forced colors page missing color swatches

Page 43: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Component requirements

1. Retain the color swatch2. Prevent swatch rendering

on top of any given background color (muddy?)

3. Preserve the user’s color scheme for text legibility

Page 44: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Prior art: media query syntax

@media (-ms-high-contrast: active) {}

Values:

none (IE and early MS Edge) | active | black-on-white | white-on-black

Page 45: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Standard media query syntax

@media (-ms-high-contrast: active), (forced-colors: active) {}

Values:

none | active

Page 46: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Prior art: opt out of forced colors

@media (-ms-high-contrast: active) {

.prefs__palette {

-ms-high-contrast-adjust: none;

}

Page 47: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Opt out of forced colors

@media (-ms-high-contrast: active), (forced-colors: active) {

.prefs__palette {

-ms-high-contrast-adjust: none;

forced-color-adjust: none;

}

Page 48: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 49: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Be careful with static colors

.prefs__palette {

forced-color-adjust:

none;

background-color: #000;

}

Page 50: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Static color values are unaware of the user scheme

Page 51: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Use appropriate system colors

.c-label {

padding: .25em;

background-color:

Canvas;

color: Text;

}

Page 52: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

CSS system colors relevant to Windows High Contrast

High Contrast Theme Color CSS System Color Prior System Colors

Text Text WindowText

Hyperlinks LinkText -ms-hotlight (IE and MS Edge only)

Disabled Text GrayText

Selected Text HighlightText (foreground), Highlight (background)

Button Text ButtonText (foreground), ButtonFace (background)

Background Canvas Window

Page 53: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Full list of system colors on CSS Color Editor’s Draft

aka.ms/system-colors-draft

Page 54: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Optimize for dark / light forced colors

@media (forced-colors: active)

and (prefers-color-scheme: light){

.prefs__palette {

background: #fff;

}

}

Page 55: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Instead of removing styles…

button {

border: 0;

}

Page 56: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

…consider transparency

button {

border: 1px solid

transparent;

}

Page 57: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Browser support for forced colors (desktop)

Vendor-prefixed styling

New standards

In development behind a flag in the Chromium project

Page 58: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Testing without a Windows machine?

Virtual Machines: aka.ms/web-vms

Page 59: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)
Page 60: Tailoring the High Contrast Experience€¦ · Hyperlinks LinkText -ms-hotlight(IE and MS Edge only) Disabled Text GrayText Selected Text HighlightText(foreground), Highlight(background)

Slides, demo, and more:aka.ms/tpac-hc


Recommended