Skip to content
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

[css-color-6] Does color-contrast() need to support three color contrast comparisons? #8457

Open
CharlesBelov opened this issue Feb 16, 2023 · 1 comment

Comments

@CharlesBelov
Copy link

CharlesBelov commented Feb 16, 2023

  • please be specific (in the title and issue) about what you want to change:

So far as I can tell, color-contrast() intends to support foreground versus background. However, for sites which hide link underlining or other link marking, the site would also need to support foreground versus link and background versus link. For example, foreground versus link for WCAG 2.0 AA needs to have 3:1 contrast and background versus link for WCAG 2.0 AA needs to have 4.5:1 contrast.

So, does color-contrast also need a syntax and means to support the three-way comparison of:

  • foreground versus background
  • foreground versus link
  • background versus link
    ?
@danburzo
Copy link

danburzo commented Mar 7, 2023

I think there are two aspects worth discussing here that may influence the final syntax for contrast-color() (#7937):

  • Is there a need for an additional contrast keyword, or a different set of keywords altogether, to express the relationship between "adjacent but not overlapping" colors? ([css-color-6] color-contrast() should distinguish foreground and background #7359)
  • Is there a need for the function to support multiple constraints for the set of candidate colors? What happens when you pit the default color candidates (white, black) against possibly-conflicting constraints?

Your link color vs. text and background could possibly be expressed along the lines of:

a {
  color: contrast-color(adjacent currentColor wcag2(3), background var(--bg) wcag2(4.5), blue, violet, etc.)
}

Support for multiple constraints will most likely impose some limitations on the syntax in order to disambiguate constraints from candidate colors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants