Learning intentions
- Know and use key typography properties: font-family, font-size, font-weight, font-style, line-height, text-decoration
- Know and use colour properties:
colorandbackground-color - Understand three ways to specify a colour in CSS: named, hexadecimal, and RGB
- Understand what a hex colour code means:
#RRGGBB - Know basic layout properties:
width,height,max-width,text-align
Success criteria
- I can write CSS to control font, size, weight, style, and line spacing of text
- I can read a hex colour code and describe its approximate colour
- I can write colour values using named colours, hex codes, and RGB notation
- I can apply typography properties to create a clear visual hierarchy (h1, h2, p)
Answer before the lesson begins.
1. Which CSS property makes text appear bold?
2. What colour does the hex code #FF0000 represent?
3. Which CSS property removes the underline from a link?
Key vocabulary
font-family: sans-serif or font-family: 'Arial', sans-serif.px (pixels) and rem (relative to the root font size).normal, bold, or numeric (100β900, where 400 = normal, 700 = bold).normal or italic.underline, none (removes underline). Browsers add underlines to links by default.#RRGGBB. Each pair (00βFF) controls the red, green, and blue channel. E.g. #FF0000 = red.rgb(255, 0, 0) = red.left, center, right, justify.CSS: Typography, Colour and Layout
Typography properties
Typography refers to how text is presented β typeface, size, weight, and spacing. Good typography makes a page easier to read and more visually appealing. CSS provides a set of properties specifically for text:
| Property | What it controls | Example |
|---|---|---|
font-family | The typeface used | font-family: sans-serif; |
font-size | The text size | font-size: 1.5rem; |
font-weight | Boldness of the text | font-weight: bold; |
font-style | Normal or italic | font-style: italic; |
line-height | Vertical space between lines of text | line-height: 1.7; |
letter-spacing | Horizontal space between letters | letter-spacing: 0.05em; |
text-decoration | Underline, none, etc. | text-decoration: none; |
text-align | Horizontal alignment | text-align: center; |
p { font-family: sans-serif; font-size: 1rem; line-height: 1.7; color: #4a4a6a; }
Colour in CSS
Two main colour properties exist in CSS:
colorβ sets the text colourbackground-colorβ sets the background fill of the element
There are three main ways to write a colour value:
| Format | Syntax | Example |
|---|---|---|
| Named colour | A colour keyword | color: red; |
| Hexadecimal | #RRGGBB | color: #FF0000; |
| RGB | rgb(r, g, b) | color: rgb(255, 0, 0); |
Understanding hex colour codes
A hex colour code follows the format #RRGGBB β six hexadecimal digits split into three pairs:
- RR β the amount of red (00 = none, FF = maximum)
- GG β the amount of green (00 = none, FF = maximum)
- BB β the amount of blue (00 = none, FF = maximum)
Each pair is a hexadecimal number from 00 to FF, equivalent to 0β255 in decimal.
Memory aid: Think of mixing red, green, and blue light (like screen pixels). FF = full brightness, 00 = no brightness. #FFFFFF mixes all three at full brightness = white. #000000 has none of any colour = black.
Each pair of hex digits controls one colour channel β 00 is none, FF is maximum
Creating a typographic hierarchy
A well-designed page has a clear visual hierarchy β headings look different from subheadings, which look different from body text. CSS lets you define this consistently:
h1 { font-size: 2.5rem; font-weight: 700; color: #042C53; } h2 { font-size: 1.5rem; font-weight: 600; color: #185FA5; } p { font-size: 1rem; line-height: 1.7; color: #4a4a6a; }
Layout basics
Several CSS properties control the size and position of elements on the page:
| Property | What it does |
|---|---|
width | Sets a fixed width for the element |
height | Sets a fixed height for the element |
max-width | Sets the maximum width β the element can be narrower but not wider |
text-align | Aligns the text within the element: left, center, right, justify |
Worked examples
What colour is rgb(0, 128, 255)? Convert it to its approximate hex equivalent.
00. 128 in hex β 80. 255 in hex = FF.#0080FF β a medium-to-bright blue with a small amount of green, giving it a slightly cyan tint./* RGB and hex are equivalent */ p { color: rgb(0, 128, 255); } p { color: #0080FF; } /* same colour */
Write CSS to create a consistent typographic hierarchy for a page: h1 with font-size 2.5rem, font-weight 700, colour #042C53; h2 with font-size 1.5rem, font-weight 600; paragraphs with font-size 1rem, line-height 1.7, colour #4a4a6a.
h1 { font-size: 2.5rem; font-weight: 700; color: #042C53; } h2 { font-size: 1.5rem; font-weight: 600; } p { font-size: 1rem; line-height: 1.7; color: #4a4a6a; }
Style a page with a consistent colour scheme: body background #f8f8fc, header background #185FA5 with white text, footer same as header.
body { background-color: #f8f8fc; } header { background-color: #185FA5; color: #ffffff; padding: 1rem; } footer { background-color: #185FA5; color: #ffffff; padding: 1rem; }
Write CSS rules that:
- Set the
bodyto usesans-serifas its font-family - Give
h1a colour of#042C53(as a hex code) and make it bold using font-weight - Make all
emelements italic using font-style - Remove the underline from all
aelements using text-decoration
body { font-family: sans-serif; } h1 { color: #042C53; font-weight: bold; } em { font-style: italic; } a { text-decoration: none; }
color (text) with background-color (fill). Setting color: white on a dark header makes the text white β it does not fill the background. Always use background-color for the fill behind an element.#FFF is valid CSS shorthand for #FFFFFF, but #FA5 is not the same as #FA0050 β it expands to #FFAA55. When working from specific hex codes, always use the full 6-digit form.font-style: bold instead of font-weight: bold. font-style only accepts normal or italic. Bold text is controlled by font-weight.text-decoration: none on links in navbars. Browsers add underlines to all <a> elements by default. To create a clean navigation bar, you must explicitly set text-decoration: none on the links.Hex colour questions are reliable marks at N5. Given a hex code like #42A5F5, you should be able to reason about the colour: the red channel is 42 (low), the green channel is A5 (medium), the blue channel is F5 (high) β so this is a light-to-medium blue. You do not need to calculate exact decimal values β just reason about which channel is highest and give a rough colour description.
The question "describe two ways to specify a colour in CSS" is commonly worth 2 marks. Know at least two formats (named, hex, RGB) with one example each.
Questions 1β3 are auto-checked. Questions 4β8 are self-marked β write your answer, then reveal the model answer to check your work.
1. What does the CSS property line-height control? TYPE 1
2. Which CSS value makes text appear in italics? TYPE 1
3. What does the hex colour #FFFFFF represent? TYPE 1
4. Given the hex code #42A5F5: describe approximately what colour it is and explain your reasoning using the RRGGBB structure. (2 marks) TYPE 2
Reasoning: The code is #42A5F5.
RR = 42 β low red value (42 out of FF = about 26% red)
GG = A5 β medium green value (about 65%)
BB = F5 β high blue value (about 96%)
The blue channel is dominant and very high, green is moderate, and red is low. This gives a bright, somewhat light blue β similar to a clear sky colour.
1 mark for identifying it as a shade of blue; 1 mark for correctly explaining which channel is dominant using the RRGGBB structure.
5. Write a CSS rule for an h2 element with the following properties: font-family sans-serif; font-size 1.4rem; colour #185FA5 (using a hex value); font-weight 600. (2 marks) TYPE 2
h2 {
font-family: sans-serif;
font-size: 1.4rem;
color: #185FA5;
font-weight: 600;
}
1 mark: correct selector and all four properties present. 1 mark: correct syntax (colon between property:value, semicolons, closing brace).
6. Explain the difference between the color and background-color CSS properties. Give an example of when you would use each. (2 marks) TYPE 2
color sets the colour of the text inside an element.Example:
p { color: #1a1a2e; } β makes paragraph text dark navy.background-color sets the fill colour behind an element β the area behind the text and padding.Example:
header { background-color: #185FA5; } β gives the header a blue background.1 mark per property with correct explanation + example.
7. Write CSS rules for body, h1, h2, and p to create a consistent typographic hierarchy for a school club website. Choose appropriate font-sizes, font-weights, and colours that form a clear visual hierarchy. (4 marks) TYPE 2
body {
font-family: sans-serif;
background-color: #f8f8fc;
color: #1a1a2e;
}
h1 {
font-size: 2rem;
font-weight: 700;
color: #042C53;
}
h2 {
font-size: 1.4rem;
font-weight: 600;
color: #185FA5;
}
p {
font-size: 1rem;
line-height: 1.7;
color: #4a4a6a;
}
1 mark per selector (correct properties with clear hierarchy β h1 larger/darker than h2, h2 larger/more prominent than p). Accept any reasonable values that demonstrate a clear visual hierarchy.
8. Describe two ways to specify a colour in CSS. For each way, give one example. (2 marks) TYPE 2
1. Named colour β using a CSS colour keyword. Example:
color: red;2. Hexadecimal (hex) β using a 6-digit #RRGGBB code. Example:
color: #FF0000;3. RGB β using rgb(r, g, b) with values 0β255. Example:
color: rgb(255, 0, 0);
Suggested timing: Single 1-hour period. Spend approximately 20 minutes on notes/examples (focus on hex colours β they take the longest to grasp), 10 minutes on now-you-try, 30 minutes on task set (Q1βQ6 in class; Q7βQ8 as extension or start of next lesson).
Hex colour activity: Show a before/after split on the projector β the same HTML page, one with no CSS and one with a consistent colour scheme and typography. Ask which is more readable and why. This motivates the lesson before any explanation.
The hex mixing metaphor: Explain hex as mixing coloured light (not paint). Red + Green + Blue light at full brightness = white. None of any = black. This is the opposite of mixing paint pigments and often surprises pupils.
Q4 is excellent exam preparation β pupils must reason about channel dominance without doing exact conversions. Drilling this type of question now pays off significantly in the exam.