Skip to content

[css-color-6] color-contrast() should distinguish foreground and background #7359

@LeaVerou

Description

@LeaVerou

As we move towards a color-contrast() function that is more flexible and allows specifying the algorithm used (see #7356), we run into the issue that many (most?) contrast algorithms are not commutative operations; it makes a difference which of the two colors is background and which one is foreground. Currently, color-contrast() does not distinguish between the two, but we think the syntax should make it clear which one is which.

While the most common case is to provide a fixed background color and multiple candidates for the foreground color, we think the reverse should be possible as well (fixed foreground, variable background). We do not think there are enough use cases that warrant the complexity of providing multiple candidates for both.

@fantasai suggested the following syntax, which also addresses the syntax concerns raised in #7354: color-contrast([over | under] <color>, <color>#) (target level omitted from this grammar for simplicity)

(Issue filed following breakout discussions between @svgeesus, @fantasai, @argyleink and myself)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Tuesday

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions