Motion-related Criteria
2.3.1 Three Flashes or Below Threshold — avoid anything that flashes more than three times in any one second period.
2.3.3 Animation From Interactions — motion animation triggered by interaction can be disabled, unless the animation is essential to the functionality or the information being conveyed.
Reducing Motion
We can use the prefers-reduced-motion
media query to remove motion for those that have set an operating system setting.
Note that lack of this setting does not necessarily mean a user is OK with motion, as they may just not be aware this setting exists.
In this snippet from Andy Bell's Modern CSS Reset, animations will run once and transtions will happen instantly. Duration is maintained so that any attached JavaScript events (animationend
or transitionend
) will still complete.
Be sure to test the results as sometimes this may have an unintended consequence of stopping an animation in a less than ideal state.
CSS for "Respecting prefers-reduced-motion"
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
}
Color and contrast criterion
1.4.3 Contrast Minimum — provide enough contrast between text and its background so that it can be read by people with moderately low vision.
Note that no criteria currently indicate a requirement for “dark mode” or varying contrast modes.
Color and Contrast Feature Media Queries
All media queries adapt to operating system preference
prefers-color-scheme
- Explicitly define properties for “light” or “dark” color schemes
- No requirement that “dark” is black, and “light” is white
@media (prefers-color-scheme: dark) {
/* "dark" mode */
}
@media (prefers-color-scheme: light) {
/* "light" mode */
}
Learn more about how color-scheme works.
Related property: color-scheme
- Indicate a page supports light, dark, or both
- If set on :root or via meta tag, Chrome will auto-apply adjustments using system colors
- Order listed indicates preference
:root {
color-scheme: dark light;
}
<meta name="color-scheme" content="dark light">
Related function: light-dark()
Note: Cutting-edge, partial browser support.
This function allows responding to the values of color-scheme
with your own custom colors. The first value listed responds to a "light" color-scheme, and the second value to a "dark" color-scheme.
CSS for "Using color-scheme and light-dark()"
:root {
color-scheme: light dark;
--text-color: light-dark(mediumvioletred, cyan);
}
p {
color: var(--text-color);
}
Adjust your color theme preference to see the change of this text color
prefers-contrast
@media (prefers-contrast: no-preference) {}
@media (prefers-contrast: less) {}
@media (prefers-contrast: more) {}
@media (prefers-contrast: custom) {}
- no-preference - Not set in operating system
- custom - User defined contrast preference, implied if forced-colors query would match
Review the spec details for the prefers-contrast media feature.
While not official guidance, the following are considerations for "less" vs "more" contrast from the user experience perspective based on the spec and notes within articles found in the additional resources.
"less" contrast
Helps users with light sensitivity (photophobia), reduces migraine trigger
- Decrease text vs. background contrast
- Soften color contrast shifts between large areas
- Reduce brightness
“more” contrast
Helps users read text & see details, distinguish UI, counter low-vision impairments (ex. Glaucoma)
- Increase text vs. background contrast
- Increase use/width of borders
- Remove box-shadows and other soft details
forced-colors
Increases text legibility through color contrast via built-in or user-defined color palettes.
@media (forced-colors: active) {}
@media (forced-colors: none) {}
active
means the user's selected theme will overwrite your palette with system colors.
forced-colors
media query intent:
- Resolve colors for SVG icons
- Retain custom colors for critical features (ex. product color swatches)
- Resolve issues from lost color (ex. replace box-shadows with borders)
Authoring for feature queries
prefers-color-scheme - provide darker and lighter versions that still fully use brand colors and high-fidelity visuals
prefers-contrast - provide “more” and “less” contrast versions that may require modified palettes and assets
forced-colors - only use to correct for loss or change of color in critical elements
Additional resources
- Prefers-contrast: forced is a mistake gives more history on prefers-contrast and further points for consideration
- Beyond screen sizes: responsive design in 2020 discusses the various feature queries
- Operating System and Browser Accessibility Display Modes explains why users choose various OS settings (pre-dates availability of some of the corresponding feature queries)
- Styling for Windows high contrast with new standards for forced colors
- CSS Color Adjustment Module Level 1 with more info about
color-scheme
and theforced-colors
behavior - Accessible Web Animation: The WCAG on Animation Explained
- Understanding SC 2.3.1: Three Flashes or Below Threshold
- Understanding SC 2.3.3: Animation from Interactions
- Understanding SC 1.4.3: Contrast (Minimum)
- light-dark explainer article from Bramus Van Damme