Lighthouse: "Background and foreground colors do not have a sufficient contrat ratio." Really?

Created on 26 Jun 2018  路  8Comments  路  Source: GoogleChrome/lighthouse

Bug report

Provide the steps to reproduce

  1. Run LH on any webpage (for example on youtube.com).

What is the current behavior?

I have this on my webpage:
screenshot_186
Lighthouse:
screenshot_187

CSS:

div#warningbackground { background-color: #ff0000; }
span#warningtext {
    color: #ffffff;
    font-size: 20px;
}
span#warningtext a {
        background-color: #ffffff;
    padding: 2px 5px 4px 5px;
    color: #0000ff;
}

What is the expected behavior?

I think contrast ratio is more than OK.

Environment Information

  • Affected Channels:
    *Chrome: 67.0.3396.99
    a337fbf3c2ab8ebc6b64b0bfdce73a20e2e2252b-refs/branch-heads/3396@{#790}
  • Operating System: Windows 10

V8 6.7.288.46
Related issues

Most helpful comment

@englishextra axe-core v4.x appears to resolve this issue (I can't duplicate the above issue in via @axe-core/cli on 4.0.2, as seen running the specific color-contrast rule on the cli below).

image

Currently, we're pegged to 3.5.5, but this is on the v7 roadmap for update in #11207

All 8 comments

The color contrast check is extended from the AxeAudit, which verifies that foreground and background colors meet the WCAG 2 AA contrast ratio thresholds. In your case, the defined colors foreground #ffffff and background #ff0000 only have a contrast ratio of 4.00:1, which (correctly) does not pass the audit.

Yup, @justinribeiro hit the nail on the head 馃憤

@Mlocik97-issues you can use a site like http://contrast-ratio.com/ to play around with colors that have sufficient color contrast.

Another resource to play around with is https://dequeuniversity.com/rules/axe/3.1/color-contrast

Well, this is outrageous:

FFFFFF on #252E31 do not have a sufficient contrast ratio.

2020-10-18_000601
2020-10-18_000632
2020-10-18_001108

checked URL

@englishextra that almost certainly is because of the offscreen slides that page has that mess up background color detection. Separate bug welcome though I don't know if we'll be able to do much about it (axe seems to just skip them in latest version).

@englishextra axe-core v4.x appears to resolve this issue (I can't duplicate the above issue in via @axe-core/cli on 4.0.2, as seen running the specific color-contrast rule on the cli below).

image

Currently, we're pegged to 3.5.5, but this is on the v7 roadmap for update in #11207

@justinribeiro Oh yeah, thanks a lot. Good news.

Was this page helpful?
0 / 5 - 0 ratings