Skip to content

[css-color-adjust-1] Move color-scheme meta to HTML #3846 #5540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 5 additions & 41 deletions css-color-adjust-1/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ Opting Into a Preferred Color Scheme: the 'color-scheme' property {#color-scheme
To ensure particular foreground or background colors,
they need to be specified explicitly.

Note: [[HTML]] specifies a
<a href="https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme">color-scheme</a>
<{meta}> tag which can be used to set the color-scheme on the root element as
a [[css-cascade-4#preshint|non-CSS presentational hint]].

Note: Earlier versions of this property also defined an <css>only</css> keyword
to be specified alongside a preferred color scheme,
indicating a stronger author preference.
Expand Down Expand Up @@ -260,47 +265,6 @@ Effects of the Used Color Scheme {#color-scheme-effect}
via elements intended for graphics
(such as <{img}> elements embedding an SVG document).

The "color-scheme" <{meta}> value {#color-scheme-meta}
---------------------------------

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 'color-scheme' value can also be provided in a <{meta}> element.

If any <{meta}> elements are [=inserted into a document=] or [=removed from a document=],
or existing <{meta}> elements have their <{meta/name}> or <{meta/content}> attributes changed,
user agents must run the following algorithm:

<div algorithm="find the color-scheme meta">
1. Let |candidate elements| be the list of all <{meta}> elements that meet the following criteria,
in [=tree order=]:

* the element is [=in a document tree=]
* the element has a <{meta/name}> attribute,
whose value is an [=ASCII case-insensitive=] match for <code>color-scheme</code>
* the element has a <{meta/content}> attribute,
whose value is not the empty string
* the element is a child of the [=the head element=] of the document

2. For each |element| in |candidate elements|:
1. If |element|’s <{meta/content}> attribute's value
[=CSS/parses=] as a <'color-scheme'> value,
treat that value as a declaration of the 'color-scheme' property on |element|’s [=tree/root=],
cascaded as a [[css-cascade-4#preshint|non-CSS presentational hint]].
Then return.

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 how CSS fallback works for properties,
the multiple <{meta}> elements must be arranged
with the legacy values <em>after</em> the newer values.
</div>

Issue(#3846): This algorithm favors the first <{meta}>,
to allow for ASAP rendering with a chosen color scheme.
Is that the desired behavior?


Forced Color Schemes: the 'forced-color-adjust' property {#forced}
====================
Expand Down