Jacob Ford Jacob Ford - 2 months ago 10
CSS Question

Could `currentBackgroundColor` become a valid, useful CSS color value keyword?

CSS3 defines

currentColor
as a color equivalent to an element’s
color
property. It’s sorta kinda like a CSS variable, but on a per-element basis. When
currentColor
is used as a color value in any CSS property, it computes to whatever is the
color
value for the element to which it is applied.

So, my question is not whether something
currentBackgroundColor
exists—I have combed through the CSS3 Color specification and am fairly confident it does not—but whether it could exist.

Borrowing from the
currentColor
definition, I presume
currentBackgroundColor
would be defined as something like:


The value of the ‘background-color’ property. The computed value of the ‘currentBackgroundColor’ keyword is the computed value of the ‘background-color’ property. If the ‘currentBackgroundColor’ keyword is set on the ‘background-color’ property itself, it is treated as ‘background-color: inherit’.


Can anyone point to any implementation issues which I may not be considering?

Answer

Can anyone point to any implementation issues which I may not be considering?

Yes. There could be circular dependencies:

* {
  background-color: current-color;
  color: current-background-color;
}

Moreover, currentcolor can be useful because text has a single color. But backgrounds usually have additional things like background-images and such. Lots of people only set a background image without caring about a fallback background color, which remains transparent. And then current-background-color is not much useful.