-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Define <meta name=supported-color-schemes> #4504
Comments
Multi-implementer interest, yay! I trust appropriate CSSWG folks are involved in vetting this design? Maybe @dbaron from Mozilla would be good to ping explicitly. The draft makes sense to me, probably with a few more cross-links in the final version. Can you submit a pull request which we could iterate on? I guess one issue is that |
I guess there is a basic question though, of why Safari shipped and Chrome desires to ship <meta name="supported-color-schemes" content="..."> instead of <html style="supported-color-schemes: ..."> What other CSS properties to we plan on duplicating in this way? |
I suspect the CSS property came later here. |
Safari and WebKit support and ship both. The meta values are the base values for the document and CSS overrides. The meta declaration is mostly needed and used by clients that need to know the color schemes before loading — macOS Mail uses it during its auto darkening decision. |
I don't quite understand the use case there; both of my snippets seem workable "before loading". Regardless, it's not clear that we want to propagate this requirement from macOS Mail onto the open web. Maybe @lilles could say more about use cases that are important to Chromium's customers? |
For sites using a CSP without |
@Zirro that raises the question then, of how many other CSS properties are we going to turn into meta tags? If in general inline CSS is not usable for some people, should we just make it possible to specify any CSS property of the document via meta tags? I'm not sure this is the right level at which to address peoples' tooling difficulties. Note that all CSS loads are render-blocking, so I don't know why color scheme would need to be discovered more-early than other things like background or text color. |
The general CSS tracking issue for this is w3c/csswg-drafts#3807; @fantasai and I spent time yesterday reviewing the several color-adjusting proposals from the last year and synthesized them into a compatible set of proposals. We suggest shortening the names of the color-scheme parts (to just
"Render-blocking" doesn't stop browsers from doing the initial "all white" render; avoiding that as much as possible is very important for dark mode.
That's not a bad idea. |
Circumventing CSP through |
heads-up to @whatwg/documentation |
MDN docs need recorded at https://trello.com/c/xMWeNiAh/156-html-meta-element |
Since I was pinged here -- I'd note I've already explained what I'm not particularly happy about with this design: w3c/csswg-drafts#3299 (comment) |
https://bugs.webkit.org/show_bug.cgi?id=193931 Reviewed by Simon Fraser. Source/WebCore: Drop support for comma as a valid seperator in <meta name="color-scheme"> to match the proposal being tracked by: whatwg/html#4504 Tests: css-dark-mode/color-scheme-meta.html css-dark-mode/older-syntax/supported-color-schemes-meta.html * dom/Document.cpp: (WebCore::isColorSchemeSeparator): Drop support for comma. LayoutTests: * css-dark-mode/color-scheme-meta-expected.txt: * css-dark-mode/color-scheme-meta.html: * css-dark-mode/older-syntax/supported-color-scheme-meta-expected.txt: * css-dark-mode/older-syntax/supported-color-schemes-meta.html: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@244413 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Note that the |
Awesome! Spec text looks pretty good at first glance. But yeah, we're trying to centralize all the UA-affecting meta values in HTML; if you'd be up for moving it over here that'd be lovely. (And sorry in advance for Wattsi.) |
As a web designer who follows HTML and CSS working groups, I'm really baffled by this introduction of a new meta property to HTML for something that is entirely dependent on the available stylesheets. I'd appreciate if somebody could clarify a few things to me. What is the advantage of the meta property compared to specifiying a color-scheme attribute that would be applied to stylesheets, e.g. |
@aaaxx When the browser strictly relies on stylesheet, it can’t make safe assumption of the purpose of the stylesheet, and everything can happen: maybe the stylesheets won’t load, or maybe it’ll load and be broken, or some JavaScript will load other stylesheets that overwrite the main one, or the stylesheet only cover a small part of the layout (see example below)… Your example ( Imagine this use case: a developer’s blog where there’s only a light theme, loaded without media condition (light is default). <!-- blog only having a light theme -->
<link rel="stylesheet" src="main.css" /> Now let’s say this developer’s blog is using a code highlighting plugin that supports light and dark color schemes, split in two dedicated CSS files: <!-- code highlighting plugin -->
<link rel="stylesheet" src="code-light.css" media="prefers-color-scheme: light" />
<link rel="stylesheet" src="code-dark.css" media="prefers-color-scheme: dark" /> If the browser considers the page is having a dark color-scheme available juste because because of the The browser can’t make correct assumptions of the layout parts covered by a stylesheet, and the only way for the browser to make a correct assumption of the page color-scheme is to load all its HTML, CSS and JS files. Hence the proposed |
OK, that makes sense, especially the case of JavaScript-loaded stylesheets. One more thing: how will this interact with user stylesheets and alternative style sheets? (There's still potential for color flashing if their color schemes differ from the meta.) |
Added this value for the `name` property on the `<meta>` element. Currently supported only in Safari 12.1 for Mac and 12.2 for iOS. whatwg/html#4504
Added this value for the `name` property on the `<meta>` element. Currently supported only in Safari 12.1 for Mac and 12.2 for iOS. whatwg/html#4504
https://bugs.webkit.org/show_bug.cgi?id=193931 Reviewed by Simon Fraser. Source/WebCore: Drop support for comma as a valid seperator in <meta name="color-scheme"> to match the proposal being tracked by: whatwg/html#4504 Tests: css-dark-mode/color-scheme-meta.html css-dark-mode/older-syntax/supported-color-schemes-meta.html * dom/Document.cpp: (WebCore::isColorSchemeSeparator): Drop support for comma. LayoutTests: * css-dark-mode/color-scheme-meta-expected.txt: * css-dark-mode/color-scheme-meta.html: * css-dark-mode/older-syntax/supported-color-scheme-meta-expected.txt: * css-dark-mode/older-syntax/supported-color-schemes-meta.html: Canonical link: https://commits.webkit.org/211299@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244413 268f45cc-cd09-0410-ab3c-d52691b4dbfc
I'd like to point out what I believe is a gap in the concept authors may need to dynamically set content (different image for each scheme) according to current active scheme but the only available option is the say my OS is set to dark, <meta name="color-scheme" content="light"> will render the page as light theme but @media (prefers-color-scheme: dark) {
fieldset {
background-color: darkslategray;
}
} will still apply even though the UA is set to light furthermore, as |
btw can content be extended to contain more values? e.g. |
Split out from proposal in w3c/csswg-drafts#3299
Apply is shipping in Safari 12.1. Chrome wants to ship this. There is a proposal draft at:
https://lilles.github.io/specs/supported-color-schemes-meta.html
with a related css-ui property proposal draft at:
https://lilles.github.io/specs/supported-color-schemes.html
The text was updated successfully, but these errors were encountered: