CSS color values, online
Six activities your students do on their own devices. See who's finished, and their scores.
CSS color values in one minute
What students need to know
240 on the colour wheel is blue, 100% saturation is fully vivid, 50% lightness is the midpoint between black and white. CSS has 140+ named colour keywords. They are clear and readable but offer less precise control than hex, rgb(), or hsl().
Each channel in rgb(r, g, b) must be between 0 and 255. 360 is the range for the hue in hsl(), not for rgb(). 3-digit hex is shorthand for 6-digit hex. Each digit is doubled: #f00 expands to #ff0000, which is pure red.
Mistakes students make
- #GGHHII is not valid hex. Hex colour values use only digits 0–9 and letters A–F. A valid example: #1a2b3c.
- The rgb() function requires commas between values: rgb(255, 0, 0), not rgb(255 0 0) without commas.
- The hsl() function requires commas between values: hsl(120, 100%, 50%), not hsl(120 100% 50%) without commas.
- Hex colour values must start with a # symbol: a { color: #0000ff; }.
What students will learn in this module
Every question in Module 41
Quick questions
- Which CSS colour format uses hue, saturation and lightness?Argb()Bhsl()
- What is the valid range for each channel in rgb()?A0 to 255B0 to 360
- True or false: #f00 and #ff0000 represent the same colour.ATrueBFalse
- What does the alpha channel control in rgba()?ATransparency (0 = fully transparent, 1 = fully opaque)BBrightness (0 = dark, 1 = bright)
- True or false: hex colour values can use letters G, H, I.ATrueBFalse
Key terms
Students type the meaning of:
#rrggbb
Match the pairs
p { color: #ff0000; }Match it to what it doesdiv {
background-color: rgba(0, 0, 0, 0.5);
}Match it to what it doeshsl(hue, saturation%, lightness%) — hue is a colour wheel angle 0–360Match it to what it doesNamed colour keywords like 'red', 'navy' and 'coral' are valid CSS colour valuesMatch it to what it doesp { color: #GGHHII; }Match it to what it doesh1 { color: rgb(300, 0, 0); }Match it to what it doesFill in the blanks
p { color: ___; }Hint: Type the CSS named colour keyword for the colour red
h1 { _____: #ff0000; }Hint: Type the CSS property name used to set the text colour
p { color: ___(0, 128, 0); }Hint: Type the CSS colour function name that takes red, green and blue channel values
a { color: ___(240, 100%, 50%); }Hint: Type the CSS colour function name that takes hue, saturation and lightness values
div { color: ____(0, 0, 0, 0.5); }Hint: Type the CSS colour function name that adds an alpha transparency channel
Spot the error
Question 1
Ap { color: #GGHHII; }Bh1 { color: #ff0000; }Ca { color: rgb(0,0,255); }
Question 2
Ap { color: navy; }Bh1 { color: rgb(255 0 0); }Ca { color: hsl(240,100%,50%); }
Question 3
Ap { color: #ff0000; }Bh2 { background-color: rgba(0,0,0,0.5); }Ca { color: hsl(120 100% 50%); }
Question 4
Abody { background-color: white; }Bp { color: #3a3a3a; }Ch1 { color: rgb(255,0,0); }Da { color: 0000ff; }
Question 5
Ap { color: #333; }Bh1 { color: crimson; }Ch2 { color: rgb(0,128,0); }Dspan { color: hsl(240,100%,50%); }Ea { color: rgba(255,0,0,1.5); }
