WebAIM - Web Accessibility In Mind

E-mail List Archives

numeric contrast checks


From: Carol Foster
Date: Jan 7, 2003 8:32AM


I am looking for an algorithm to check for color contrast based on HTML
color codes - is this possible? I believe that A-Prompt uses something
like this - at least it identified contrast issues and suggested
alternative colors when I tried it out maybe a year or 2 ago.

Looking back through previous discussions on this list, the most numeric
info I found was from Philip Lanier - he said:

[beginning of quote]

"For individuals who have normal 20/20 vision, the general rule of thumb
that the two shades should differ by 70% to have good readability. 70%
difference means the difference in absolute percentages. So you could
100% black on 30% gray. Or 10% gray (near white) on 80% gray.

With regard to color, it is best to differentiate based on luminance
rather than hue or saturation, as the human perceptual system can only
differentiate between about 200 colors (hues), 20 saturations, but can
distinguish around 500 different shades (lightnesses).

Also, keep in mind that users may have varying degrees of
and some may have limited or no sight. So always provide a text
equivalent of every non-text element! If you must differentiate based on

color in an image, there are schemes that work well for readers who are
colorblind. A very gross generalization to remember that for the
of people who are colorblind, reds and greens will appear yellowish.
I said, this is a very gross generalizatoin... for a much more in-depth
discussion, check out www.vischeck.com."

[end of quote]

Can this be translated into the terms of HTML color codes?

I did check out vischeck and some links in bobby and lighthouse, but I
did not have a lot of time. Maybe this is a big research project with
no quick answers, but if anyone does have an algorithm like this, or
some numeric tips more intended for HTML techies who don't know too much
about color theory, I would be most grateful.

Best wishes,

Carol Foster, Web Developer
Internet Publishing Group, Information Technology Services
University of Massachusetts, President's Office
phone: (413) 587-2130
fax: (413) 587-2148

To subscribe, unsubscribe, or view list archives,
visit http://www.webaim.org/discussion/