@@ -2764,15 +2764,67 @@ or any other color or monochrome output device which has been characterized.
27642764 System colors have the ability to react to the current used ''color-scheme'' value.
27652765 The ''light-dark()'' function exposes the same capability to authors.
27662766
2767+ There are two forms of this function: one takes a pair of colors
2768+ while the other takes a pair of images.
2769+
27672770 <pre class='prod'>
2768- <dfn export>light-dark()</dfn> = light-dark( <<color>> , <<color>> )
2771+ <dfn export>light-dark()</dfn> = light-dark( [ <<color>> , <<color>> ] | [ <<image>> , <<image>> ] )
27692772 </pre>
27702773
2771- This function computes to the computed value of the first color,
2774+ For the color form, this function computes to the computed value of the first color,
27722775 if the <a>used color scheme</a> is ''light'' or unknown,
27732776 or to the computed value of the second color,
27742777 if the <a>used color scheme</a> is ''dark'' .
27752778
2779+ For the image form, this function returns the first image,
2780+ if the <a>used color scheme</a> is ''light'' or unknown,
2781+ or the second image,
2782+ if the <a>used color scheme</a> is ''dark'' .
2783+
2784+ <div class="example" id="ex-light-dark-color">
2785+ For example, to maintain a legible contrast on links,
2786+ for light mode and dark mode:
2787+
2788+ <pre class="lang-css">
2789+ a:link {
2790+ color: light-dark(blue, #81D9FE);
2791+ background-color: light-dark(white, black);
2792+ }
2793+ </pre>
2794+
2795+ The traditional <span class="swatch" style="--color: blue"></span> blue link text
2796+ is legible on a <span class="swatch" style="--color: #fff"></span> white background
2797+ (WCAG contrast 8.59:1, AAA pass)
2798+ but would not be legible on a <span class="swatch" style="--color: #000"></span> black background
2799+ (WCAG contrast 2.44:1, AA fail).
2800+ Instead, a lighter blue <span class="swatch" style="--color: #81D9FE"></span> #81D9FE
2801+ is used in dark mode.
2802+ (WCAG contrast 13.28:1, AAA pass).
2803+
2804+ <div style="margin:1em; margin-left: 2em; text-decoration: underline; background: inherit">
2805+ <p style="padding: 4px; background-color: white; color: blue"> Legible link text</p>
2806+ <p style="padding: 4px; background-color: black; color: blue"> Illegible link text</p>
2807+ <p style="padding: 4px; background-color: black; color: #81D9FE"> Legible link text</p>
2808+ </div>
2809+ </div>
2810+
2811+ <div class="example" id="ex-light-dark-image">
2812+ For example, to provide easily visible list bullets
2813+ for light mode and dark mode:
2814+
2815+ <pre class="lang-css">
2816+ ul.fancy {
2817+ list-style-image: light-dark(
2818+ url("icons/deep-maroon-ball.png"),
2819+ url("icons/pale-yellow-star.png")
2820+ );
2821+ }
2822+ </pre>
2823+
2824+ </div>
2825+
2826+
2827+
27762828 <wpt>
27772829 light-dark-basic.html
27782830 light-dark-currentcolor.html
@@ -2819,6 +2871,7 @@ or any other color or monochrome output device which has been characterized.
28192871 <wpt>
28202872 contrast-color-001.html
28212873 contrast-color-currentcolor-inherited.html
2874+ animation/contrast-color-interpolation.html
28222875 parsing/color-computed-contrast-color-function.html
28232876 parsing/color-invalid-contrast-color-function.html
28242877 parsing/color-valid-contrast-color-function.html
0 commit comments