Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Background on color perception:

Due to the nature of the human eye and visual processing by the brain, there's an optical illusion that the same color will look different depending on the background.

It is known as the contrast effect, illustrated below — center rectangles are identical:

enter image description here Source: Wikimedia

An illustration (and report) by NASA makes the effect of the background's color even more obvious:

enter image description here

enter image description here Source: NASA Color Usage Research Lab

(Note how the two upper-most colors in the second image appear the same, but are actually completely different.)

What about web design?

My question pertains to web design, specifically in this case, the color of link text on different backgrounds.

For a given color of text, how can one find the complementary color to make it appear the same on a certain background?

Let's take a look at an example for this question:

Consider my example below, with yellow text #FFF000 on the following backgrounds:

  • white #FFFFFF,
  • black #000000,
  • and grey #555555.

Compare colors on different backgrounds for web design text

As expected, doesn't look the same at all. (View and download .PSD file here.)

How can we make it look the same on all three? Clearly, the text on the white background needs to be a darker yellow, and the one on the grey needs hue/tone adjustments. (The surrounding text will also affect it — but that's likely harder to account for.)

Can this perfect color somehow be calculated, based on the Hex, RGB or another system? That's where the crux of this question lies, as it would be much more efficient than manually approximating.

share|improve this question
You'll need to use yellows. Notice in your examples they used colors similar to the one they are trying to make look different. – Johannes Jan 30 '13 at 5:37
@Johannes, what do you mean? – Baumr Jan 30 '13 at 5:40
In your first example the colors used were all shades of gray. In your second example your purple was made to look more blue through the use of a very bright purple. Then in your yellow example you're butting yellow of whites, grays, and blacks. So what I'm saying is you need to use yellows instead to make your yellow appear the same on different backgrounds. – Johannes Jan 30 '13 at 5:47
I'm having a tough time explaining this, I apologize. – Johannes Jan 30 '13 at 5:47
up vote 8 down vote accepted

It seems like you're looking for the analogue of complementary colours, but in the lightness space rather than hue. As far I can tell, no such general mapping can exist.

Suppose you could compensate for the effect by assuming a linear correlation between the background and the foreground, so that as the background darkens the foreground text lightens by the same amount. I assume that hue remains fixed. There will always be a midpoint at which the background and the foreground share the same colour.

As an example, consider black on white. The converse lightness for the same hues is white on black, but if you tried to find a foreground for every intermediate background of the same hue, at the midway point you hit grey-on-grey and can't see anything at all.

For much the same reason, I can't see that any reasonably simple mapping — even a lossy one — can exist.

share|improve this answer
To solve this, I think we would need to build a model of the (average) human eye, and find the best fit using a genetic algorithm – Baumr Mar 5 '15 at 13:31
@Baumr: Could be a good PhD thesis :) – PreferenceBean Mar 5 '15 at 13:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.