In this lesson, you gave the paragraphs of the work day notice you built in HTML a light gray that looked readable on the pale green page, then measured its contrast against that background in DevTools’ color picker. It failed, so you dragged it darker until AA turned green.
Key Points
- Watch out: readable to you isn’t the test. Someone with low vision, someone reading a phone in bright sunlight, or someone on a dim screen sees less contrast than you do. So measure contrast instead of judging it by eye.
- Open the color picker from the Styles pane. In the Elements panel, select the paragraph under Turn the Compost. The Styles pane shows your
prule fromevents.csswith a small square of its color in front of the value. Click that square, and the color picker opens. - The picker’s big square holds the shades of one color, from white at the top left to black along the bottom, and its left edge runs through the grays. A small circle marks your color, and the value field shows its hex code. You can ignore the rest of the picker for now.
- The contrast ratio compares how light the text is with how light the background behind it is. On the notice, that’s the
honeydewfrom yourbodyrule. The scale runs from 1:1, text the same color as its background, up to 21:1, black on white. Your light gray,#999999, showed Contrast ratio 2.74 on honeydew. - No contrast information available isn’t a pass. DevTools couldn’t find the background, as happens on the notice’s date paragraph. Click the eyedropper beside Pick background color, then click the background on the page, and the ratio appears.
- WCAG AA is the level of the Web Content Accessibility Guidelines that most sites aim for. For body text, it asks for a ratio of at least 4.5:1. AAA is a stricter level, at 7:1. Click the Contrast ratio row to see both. At 2.74, both had a red mark, so the gray failed.
- Large text has lower bars, and the picker chooses them by itself from the text’s size and weight. For the notice’s heading, it showed AA: 3.0 and AAA: 4.5. That’s all you need about large text for now.
- Two white curves appear on the square. Every shade below the upper one passes AA, and every shade below the lower one passes AAA. On a light background like the notice’s, darker text means more contrast, so drag the circle down the left edge to keep it gray. The ratio climbs as the paragraphs on the page darken with it. At
#757575the ratio was 4.46, still a fail. One step further, at#737373, it was 4.59, and AA got a green check. - DevTools changes the page, not your file. The asterisk before
events.cssin the Styles pane means the change lives only in DevTools, and a reload brings back the old gray. Copy the new value into your file and save. - The rule: even a color that looks fine to you can fail, so check each text color against the background it sits on, and move it away from that background’s lightness (darker on a light background) until AA turns green at 4.5:1 for body text. Check the colors you chose in the last lesson the same way.
Final Code
events/events.css, the file from Choose Colors with the new p rule at the end and its gray darkened until it passes AA on honeydew:
events/events.css
/* Practice styles for the garden's event pages */
body {
background-color: honeydew;
color: oklch(0.247 0.05 152.7);
font-family: system-ui, sans-serif;
}
h1 {
color: oklch(0.447 0.116 152.7);
}
h2 {
color: oklch(0.347 0.08 152.7);
}
a {
color: oklch(0.447 0.116 152.7);
text-decoration-color: color-mix(
in oklch, currentColor 40%, transparent
);
}
p {
color: #737373;
}
Next, in Size Text With rem and em, you’ll decide how big that text should be, and in which unit.