Description
Consider:
<!DOCTYPE html>
<html><head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
html, body { margin: 0; padding: 0; font-size: 36px; }
html { forced-color-adjust: none; }
body { forced-color-adjust: auto; background: red; }
</style>
</head><body>
</body>
</html>
Suppose red
is not a system color, then:
- Per https://www.w3.org/TR/css-color-adjust-1/#forced-colors-properties, forced-color adjustment changes used values, not computed values (unless inherited with
forced-color-adjust: preserve-parent-color
). Therefore, the computed values follow normal rules. The computedbackground-color
ofhtml
,body
aretransparent
,red
. Moreover, the computedbackground-image
ofhtml
,body
are bothnone
. According to the adjustment rules, the used background ofbody
isCanvas
in this case. - Per https://drafts.csswg.org/css-backgrounds/#body-background, when the computed
background-color
,background-image
ofhtml
aretransparent
,none
, the computed background properties ofbody
are propagated tohtml
(as if they were "specified"), and the used background ofbody
is initial value, which istransparent
. Note that the propagated specified values tohtml
become computed values.
We reach a contradiction on the used background of body
. The order of propagation and adjustment should be specified.
In addition, regardless of the used background on body
:
- The computed background of
html
becomesred
, and itsforced-color-adjust
isnone
, so it should be red.
However, MSEdge 136.0.3240.50 (Official build) (64-bit) will show Canvas
background. Would you suggest that I file an issue with Chromium? (I don't suggest myself reporting that as a bug.)
I feel the correct definition should be this:
- The background on
body
is computed, then potentially adjusted, arriving at a used value. - If the computed background on
html
istransparent
, then it acquires the used background frombody
(not the computed ofbody
) as its own computed value and forcibly resetsbody
totransparent
background. Potentially, the background ofhtml
undergoes adjustment from its computed value (either propagated or cascaded).
I'll call the propagation condition "html
has trivial background
". Enumerate the scenarios for my proposed definition:
html
has trivialbackground
, either or both have adjustment, then the overall result isCanvas
background.html
has trivialbackground
, neither has adjustment, then the overall result is developer-specified background frombody
.html
has non-trivialbackground
, then the canvas background directly determined byhtml
(consideringhtml
willingness to adjust).
In all cases, the result is intuitive (and consistent with what MSEdge currently does).
Note that in the proposed definition, in the second step, whether the forcible reset of body
to transparent
is followed by another potential adjustment on body
, is academic and not interesting:
- Per CSS color-adjust-1, upon adjustment, the background color retains its alpha channel. Therefore, the body background simply becomes another transparent color. There is no difference in rendered result.
- Keeping
body
simplytransparent
reenforces the (correct) idea that setting onebackground
on eitherhtml
orbody
simply sets the canvas background. The range of this background has nothing to do with the bounds ofhtml
orbody
.