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

insufficient contrast error incorrectly given for 14pt bold text #155

Closed
robfentress opened this issue Feb 29, 2016 · 1 comment
Closed

Comments

@robfentress
Copy link

The following code should pass, but throws a contrast error:
<p>Sample: <span style="color: #7c7cff; background-color: #ffffff; font-size: 14pt; font-weight: bold;">I am 14pt bold text and should pass</span></p>

The error is:

This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 3.4:1. Recommendation: change text colour to #6666e9.

WCAG 2.0 AA requirement is 3:1 for large text, defined as 14 point and bold or larger, or 18 point or larger. This text is 14pt bold, and so should pass.

@luketw
Copy link
Member

luketw commented Mar 3, 2016

Hi Rob,

I'm going to accept this as a bug. It looks like my contrast calculations have an edge case that you've picked up.

They round down the calculated number of pixels returned by the computed style (based on the CSS pixel of 96 px/inch) before converting to points - and since 14pt is (18 2/3)px, it's calculating on 18px (=13.5pt) and not the full amount.
https://github.com/squizlabs/HTML_CodeSniffer/blob/master/Standards/WCAG2AAA/Sniffs/Principle1/Guideline1_4/1_4_3_Contrast.js#L69

It probably didn't come to my attention before because I had in my head the mention in the standard of "120% of the default body text", which is actually 19.2px (=14.4pt) in most browsers, hence for a moment I thought this wasn't a bug, but you're most certainly correct.

Will get to it in the next release. Thanks for the report!

ironikart added a commit that referenced this issue Aug 26, 2016
…s for the calculation are preserved and the error for the given use case is resolved. Unit test added and passing for the issue however the basic failure isn't generating with the correct code that the auditor is presenting. It's likely to be an issue with the unit test or unit test runner code rather than an actual failure to detect (works when run manually).
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