Accessible Design: Contrast, Colour Blindness and Alt Text
Learn three habits for designs more people can use: checking contrast, simulating colour vision with real matrices, and writing good alt text, with measured results.
In this lesson you will
- Check contrast for every pair
- Simulate colour vision deficiency
- Never use colour as the only signal
- Write short, useful alt text
About 25 minutes
The chart nobody could read
Anil makes a chart for the library report. Books borrowed are shown in green and books returned late in red. It looks clear on his screen. At the committee meeting, one member squints and says, ‘I cannot tell which line is which.’ He is not being difficult. He has red-green colour blindness, as do a good many people. A design that works only if everyone sees colour the same way does not work for everyone. This lesson is about three habits that make designs usable by more people: checking contrast, checking colour-blind safety, and describing images in words.
Who is affected, and by how much
A large review of studies of red-green colour deficiency found that about 8 per cent of men of European descent and about 0.4 per cent of women are affected, with lower rates among men of Chinese and Japanese ethnicity, between about 4 and 6.5 per cent. The figures vary by population and study, but the lesson is the same: in any group of a hundred people, some will see your reds and greens differently from you. Others have low vision, view a screen in bright sunlight, or print in black and white. Designing for them helps everyone.
Habit 1: contrast, again
Lessons 6 and 11 covered contrast ratios. At this level the habit is to check every text pair every time, in every theme, and to treat 4.5 for normal text and 3 for large text as the minimum, not a goal. Canva has a design accessibility tool in the File menu, which Canva describes as checking typography, colour contrast and alternative text, and it is a useful first pass. As universities who use it point out, it does not guarantee that a design is accessible, so it supports your judgement and does not replace it.
Habit 2: simulate colour vision
You can predict how colours look to someone with a colour deficiency by transforming them with a mathematical matrix. The program below uses well-known approximate matrices for the three main types: protan and deutan, the red-green kinds, and tritan, the much rarer kind that affects blues. It works on the linear form of the colour, as colour science requires, and for each pair it measures the contrast between the two simulated colours. Treat the output as an approximation, not a medical simulation.
import numpy as np
M = { # approximate colour vision matrices (severity 1.0), applied to linear RGB
"protan": [[0.152286, 1.052583, -0.204868], [0.114503, 0.786281, 0.099216], [-0.003882, -0.048116, 1.051998]],
"deutan": [[0.367322, 0.860646, -0.227968], [0.280085, 0.672501, 0.047413], [-0.011820, 0.042940, 0.968881]],
"tritan": [[1.255528, -0.076749, -0.178779], [-0.078411, 0.930809, 0.147602], [0.004733, 0.691367, 0.303900]],
}
def to_lin(h):
c = np.array([int(h[i:i + 2], 16) for i in (1, 3, 5)]) / 255
return np.where(c <= 0.04045, c / 12.92, ((c + 0.055) / 1.055) ** 2.4)
def to_hex(lin):
lin = np.clip(lin, 0, 1)
c = np.where(lin <= 0.0031308, lin * 12.92, 1.055 * lin ** (1 / 2.4) - 0.055)
return "#%02X%02X%02X" % tuple(int(round(v * 255)) for v in c)
def simulate(h, kind):
return to_hex(np.array(M[kind]) @ to_lin(h))
def lum(h):
return float(to_lin(h) @ np.array([0.2126, 0.7152, 0.0722]))
def contrast(a, b):
hi, lo = sorted((lum(a), lum(b)), reverse=True)
return (hi + 0.05) / (lo + 0.05)
pairs = [("red/green chart", "#C0392B", "#2E8B57"), ("purple/pink", "#5A28C8", "#F06CC2")]
for name, a, b in pairs:
print(name + f": normal {contrast(a, b):.2f}")
for kind in M:
print(f" {kind}: {contrast(simulate(a, kind), simulate(b, kind)):.2f}")
print("white stays:", simulate("#FFFFFF", "deutan"))
print("grey stays:", simulate("#808080", "protan"))
images = [("logo", "Cedar Library logo in purple"), ("photo", ""), ("banner", "image of a banner"),
("hero", "Children reading at low tables in the library's bright corner " * 3)]
print()
for name, alt in images:
if not alt: print(name + ": missing alt text")
elif alt.lower().startswith(("image of", "picture of")): print(name + ": starts with 'image of'")
elif len(alt) > 125: print(name + ": longer than 125 characters")
else: print(name + ": ok")
red/green chart: normal 1.28
protan: 1.83
deutan: 1.04
tritan: 1.29
purple/pink: normal 2.97
protan: 2.07
deutan: 3.01
tritan: 2.78
white stays: #FFFFFF
grey stays: #808080
logo: ok
photo: missing alt text
banner: starts with 'image of'
hero: longer than 125 characters
Read the results. The red and green of Anil’s chart have a contrast of only 1.28 to begin with, which is weak even for people with typical vision. For the deutan simulation it drops to 1.04, which means the two colours become almost the same lightness: essentially invisible as a difference. The purple and pink pair starts at 2.97 and falls to 2.07 in the protan simulation, but the two colours would still differ in lightness. The program also checks itself: white stays white and mid-grey stays grey under every matrix, as they should, because a colour-blind person sees neutral colours the same way anyone does.
The practical rule that follows is simple. Do not use colour as the only way to tell things apart. In a chart, label the lines directly, or use different line styles or markers. In a poster, add words to icons, such as ‘sold out’ beside the red mark. Where two colours must be told apart, make them differ clearly in lightness as well as hue, so that a greyscale copy still works. Test this by looking at your design in greyscale on your phone.
Habit 3: say what the picture says
Alt text is a short description of an image for people who use screen readers. Canva’s help describes adding it from the More menu, under Alternative text, and marking purely decorative items as decorative so screen readers skip them. The last part of the program shows four checks on sample descriptions. A good one, ‘Cedar Library logo in purple’, passes. An empty one is flagged as missing. One that starts with ‘image of’ is flagged, because screen readers already announce that it is an image. One that runs longer than about 125 characters is flagged. The 125 figure is the rule of thumb used in this program, not a standard, so use it as a prompt to be concise.
There is one more point. If an image contains important words, such as a date, repeat the words in text or in the alt text, because a picture of words is invisible to a screen reader. If you export a document as a PDF, review it, and avoid flattening it, since flattening turns everything into pictures. Canva’s help and many universities’ guides note that exported PDFs may need checking for structure and reading order.
Checking accessibility only at the end. By then the colours, the layout and the text are all fixed, and each fix touches the others. Check contrast when you choose colours, and add alt text as you place each image.
No tool can promise a design is accessible. Checkers find the measurable problems. Whether the order makes sense, the words are clear and the images are described well still needs a human, ideally one who uses assistive technology.
Practice for this lesson
Check what you learned
Five quick questions. Pick an answer and you will see straight away whether it is right and why.
Roughly what share of men of European descent have red-green colour deficiency?
- About 80 per cent
- About 8 per cent
- About 0.8 per cent
- About 40 per cent
Large reviews report about 8 per cent of men of European descent, and far fewer women.
What does the red and green pair become under the deutan simulation?
- Brighter and clearer
- Blue and purple
- Nearly the same lightness
- Black and white
The contrast fell to about 1, so the two colours are almost indistinguishable.
What is the safest rule about colour?
- Never use colour as the only signal
- Use more colours
- Avoid all colours
- Use only red and green
Add labels, patterns or lightness differences so the message survives without colour.
Which alt text would the checker flag?
- Cedar Library logo in purple
- Marked as decorative
- image of a banner
- A short useful description
Screen readers already say it is an image, so starting with “image of” wastes words.
What can a design accessibility tool guarantee?
- Nothing complete, it finds common problems
- Full legal compliance
- Perfect colours
- Correct reading order
Such tools catch measurable problems, but a person must judge the whole design.
Summary
- About 8 per cent of men of European descent have red-green colour deficiency, so colour alone is not enough.
- Simulation shows that red and green can collapse to the same lightness.
- Add labels, patterns and lightness differences, and check in greyscale.
- Write concise alt text, mark decoration as decorative, and review exported PDFs.
Questions
Does the checker in Canva make my design accessible?
It helps with typography, contrast and missing alt text, but it does not guarantee accessibility. A person should review the design, ideally with assistive technology.
How long should alt text be?
As short as it can be while giving the meaning. Many guides suggest a sentence or two and avoiding the words image or picture of. Our checker uses about 125 characters as a prompt, not a rule.
Are these simulations exact?
No. They are approximations used to spot problems. People with colour deficiency vary a great deal, so labels and lightness differences are the safe fix.
