Skip to content

Commit

Permalink
Specify <meta name=color-scheme>
Browse files Browse the repository at this point in the history
The specification is currently in the CSS Color Adjustment spec [1]. It
was resolved [2] in the CSSWG that it should be moved to the HTML spec,
with a reference [3] from CSS Color Adjustment.

[1]: https://drafts.csswg.org/css-color-adjust/#color-scheme-meta
[2]: w3c/csswg-drafts#3846 (comment)
[3]: w3c/csswg-drafts#3846 (comment)
  • Loading branch information
lilles authored Sep 24, 2020
1 parent 3ba8e89 commit 270640c
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -3615,6 +3615,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

<ul class="brief">
<li><dfn data-x-href="https://drafts.csswg.org/css-syntax/#conform-classes">conformant style sheet</dfn></li>
<li><dfn data-x-href="https://drafts.csswg.org/css-syntax/#parse-a-list-of-component-values">parse a list of component values</dfn></li>
<li><dfn data-x-href="https://drafts.csswg.org/css-syntax/#parse-a-comma-separated-list-of-component-values">parse a comma-separated list of component values</dfn></li>
<li><dfn data-x-href="https://drafts.csswg.org/css-syntax/#component-value">component value</dfn></li>
<li><dfn data-x-href="https://drafts.csswg.org/css-syntax/#environment-encoding">environment encoding</dfn></li>
Expand Down Expand Up @@ -3685,6 +3686,13 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<ul class="brief">
<li><dfn data-x-href="https://drafts.csswg.org/css-scoping/#flat-tree">flat tree</dfn></li>
</ul>

<p>The following terms and features are defined in <cite>CSS Color Adjustment</cite>: <ref
spec=CSSCOLORADJUST></p>

<ul class="brief">
<li><dfn data-x-href="https://drafts.csswg.org/css-color-adjust/#color-scheme-prop">'color-scheme'</dfn></li>
</ul>
</dd>


Expand Down Expand Up @@ -14220,6 +14228,77 @@ interface <dfn>HTMLMetaElement</dfn> : <span>HTMLElement</span> {
the theme color as a background and display white text over it, it might use a darker variant of
the theme color in that part of the UI, to ensure adequate contrast.</p>
</dd>

<dt><dfn><code data-x="meta-color-scheme">color-scheme</code></dfn></dt>

<dd>
<p>To aid user agents in rendering the page background with the desired color scheme immediately
(rather than waiting for all CSS in the page to load), a <span>'color-scheme'</span> value can
be provided in a <code>meta</code> element.</p>

<p>The value must be a string that matches the syntax for the CSS <span>'color-scheme'</span>
property value, and will be cascaded with the color-scheme declarations for the document root
element as described below.</p>

<p>There must not be more than one <code>meta</code> element with its <code
data-x="attr-meta-name">name</code> attribute value set to an
<span>ASCII case-insensitive</span> match for <code
data-x="meta-color-scheme">color-scheme</code> per document.</p>

<div class="example">
<p>The following declaration indicates that the page is aware of and can handle a color scheme
with dark background colors and light foreground colors:</p>

<pre><code class="html">&lt;meta name="color-scheme" content="dark"></code></pre>
</div>

<div w-nodev>

<p>To obtain a page's color-scheme, user agents must run the following steps:</p>

<ol>
<li>
<p>Let <var>candidate elements</var> be the list of all <code>meta</code> elements that
meet the following criteria, in <span>tree order</span>:</p>

<ul class="brief">
<li>The element is <span>in a document tree</span></li>
<li>The element has a <code data-x="attr-meta-name">name</code> attribute, whose value is
an <span>ASCII case-insensitive</span> match for
<code data-x="meta-color-scheme">color-scheme</code></li>
<li>The element has a <code data-x="attr-meta-content">content</code> attribute</li>
</ul>
</li>

<li>
<p>For each <var>element</var> in <var>candidate elements</var>:</p>

<ol>
<li>Let <var>parsed</var> be the result of <span data-x="parse a list of component
values">parsing a list of component values</span> given the value of <var>element</var>'s
<code data-x="attr-meta-content">content</code> attribute.</li>

<li>If <var>parsed</var> is a valid CSS <span>'color-scheme'</span> property value, then
treat that value as a declaration of the CSS <span>'color-scheme'</span> property on
<var>element</var>'s <span>root</span>, cascaded as a <span
data-x="presentational hints">presentational hint</span>, and return.</li>
</ol>
</li>
</ol>

<p>If any <code>meta</code> elements are <span data-x="node is inserted into a
document">inserted into the document</span> or <span data-x="node is removed from a
document">removed from the document</span>, or existing <code>meta</code> elements have their
<code data-x="attr-meta-name">name</code> or <code data-x="attr-meta-content">content</code>
attributes changed, user agents must re-run the above algorithm.</p>

</div>

<p class="note">Because these rules check successive elements until they find a match, an
author can provide multiple such values to handle fallback for legacy user agents. Opposite to
how CSS fallback works for properties, the multiple meta elements needs to be arranged with the
legacy values after the newer values.</p>
</dd>
</dl>


Expand Down Expand Up @@ -122795,6 +122874,9 @@ INSERT INTERFACES HERE
<dt id="refsCSSCOLOR">[CSSCOLOR]</dt>
<dd><cite><a href="https://drafts.csswg.org/css-color/">CSS Color Module</a></cite>, T. &Ccedil;elik, C. Lilley, L. Baron. W3C.</dd>

<dt id="refsCSSCOLORADJUST">[CSSCOLORADJUST]</dt>
<dd><cite><a href="https://drafts.csswg.org/css-color-adjust/">CSS Color Adjustment Module</a></cite>, E. Etemad, R. Atanassov, R. Lillesveen, T. Atkins. W3C.</dd>

<dt id="refsCSSDISPLAY">[CSSDISPLAY]</dt>
<dd><cite><a href="https://drafts.csswg.org/css-display/">CSS Display</a></cite>, T. Atkins, E. Etemad. W3C.</dd>

Expand Down

0 comments on commit 270640c

Please sign in to comment.