media-feature

prefers-contrast — CSS reference

This discrete media feature reports a contrast preference: no-preference, more, less or custom. Custom may indicate a user palette that is not well described by more or less contrast. Respond with meaningful boundary, foreground and background adjustments, without assuming the feature is itself an accessibility score.

Formal Syntax & Structure

css syntaxcss
@media (prefers-contrast: more) { … }

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS accessible theme lab</title><style>body {margin:0} .sample {height:12px;background:#006050}button{border:1px solid #767676;padding:8px}@media(prefers-contrast:more){button{border:3px solid black}}</style><body><button id="a">Save</button></body></html>
CSS Reference