siege-media / contrast-ratio

A tool to calculate the contrast ratio between any two valid CSS colors.
https://www.siegemedia.com/contrast-ratio
MIT License
2.45k stars 221 forks source link

Only works to 1 decimal point and rounds up #13

Closed KBDevelops closed 6 years ago

KBDevelops commented 8 years ago

I had an issue using this tool where the colour combination was compliant here (4.5:1) but was actually 4.47:1 according to Snook's tool, so non-compliant.

Would it be worth changing the mathematical logic to either ignore rounding or round down so that combination would have been 4.4:1?

Alternatively going for a more accurate ratio?

LeaVerou commented 8 years ago

Hmm, a more accurate value should definitely be a tooltip. Not sure about flooring, as most people care about having adequate contrast, not passing some arbitrary threshold, and a deviation of 0.05 or less from the threshold doesn't mean bad contrast. The only people who care about the precise value are those who need to pass WCAG as a legal requirement, I'd imagine.

thecristen commented 8 years ago

Some good thoughts in here.

Just to chime in, I ran into this issue today. I'm using automated testing to augment my accessiblity-checking abilities, and indeed it checks the WCAG 2.0 AA-specified arbitrary marker of 4.5:1. My test failed and I thought to come to this tool to check. Ultimately I had to go use the WebAIM tool to get the 'real' contrast number. A tooltip could have saved me the trip! ;)

gsnedders commented 8 years ago

The only people who care about the precise value are those who need to pass WCAG as a legal requirement, I'd imagine.

Yeah, I strongly suspect that is so. Unfortunately, we do exist… :(

IMO, the big button should always should always round down, so it strictly follows the "at least" wording of WCAG, and then I guess give an extra decimal digit (with round to nearest, ties away from zero) in tooltip?

I'll try and write up a PR for this either this weekend or next week.

LeaVerou commented 8 years ago

Yeah, that's a good idea and probably trivial to implement. Looking forward to the PR!

weboverhauls commented 8 years ago

+1 to @gsnedders above. People DO use this tool for legal/strict WCAG testing. An update would help eliminate confusion (as witnessed at day job today).

gsnedders commented 6 years ago

@LeaVerou Thanks for finally fixing this; sorry I never got around to it!