Take the 2-minute tour ×

Given arbitrary background colour A, the most readable colour for text would be B.

Currently I have the following solution ( that is incredibly popular but not correct ):

Turn the bg colour monotone
find the midway point between white and black,
if closer to white
    B = black
    B = white.

This however is simplistic, fails on the midtones, and does not account for the fact our eyes do not see the colour spectrum uniformly.

I read an article a few months back that explained this and showed demonstrations, showing those colours where the above failed, and the adjusted calculation worked. I cannot find it however.

As a sidenote, people seem to also answer questions like this with an algorithm to figure out contrast between two colours. I have more of those than I could ever want. I need to know how to produce the best text colour A given background colour B.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Maybe this could help you out.

Good text foreground color for a given background color

share|improve this answer
add comment

Your Answer


