concept

non-text-contrast — CSS reference

Visual information needed to identify active controls and their states, and meaningful graphical objects, generally needs a contrast ratio of at least 3:1 against adjacent colors. Exceptions include inactive controls, unmodified UA appearance and essential graphical presentation. This criterion does not require every decorative border to contrast. The example checks an authored boundary against an opaque white surface.

Formal Syntax & Structure

css syntaxcss
WCAG 2.2 SC 1.4.11: 3:1 where applicable

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}body{background:white} button{background:white;color:black;border:2px solid #949494;padding:12px} #b{border-color:#959595}</style><body><button id="a">Continue</button> <button id="b">Cancel</button><script>function luminance(rgb) { return rgb.map(n => {const s=n/255; return s<=0.04045?s/12.92:((s+0.055)/1.055)**2.4;}).reduce((sum,v,i)=>sum+v*[0.2126,0.7152,0.0722][i],0); }function contrast(a,b){const x=luminance(a),y=luminance(b);return (Math.max(x,y)+0.05)/(Math.min(x,y)+0.05);}function channels(s){return s.match(/\d+/g).map(Number);}function sampleContrast(id){const s=getComputedStyle(document.getElementById(id));return contrast(channels(s.color),channels(s.backgroundColor));}</script></body></html>
CSS Reference