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 numbers from 100 to 900 in multiples of 100 (400 = normal, 700 = bold). Modern variable fonts may support any numeric value from 1 to 1000.normal, italic, and oblique.underline, none (removes underline). Browsers usually underline hyperlinks β <a> elements with an href attribute β 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 | Upright or slanted text; common values include normal, italic, and oblique | 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; }
Sizing and text alignment
CSS can set an element's dimensions and align its inline content. These properties do not necessarily give an element a fixed size or position it on the page:
| Property | What it does |
|---|---|
width | Specifies the element's width; values can be fixed, fluid (such as a percentage), or auto |
height | Specifies the element's height; values can be fixed, relative, or auto |
max-width | Sets the maximum width β the element can be narrower but not wider |
text-align | Aligns inline content, such as text, within the element's box; it does not position the element itself |
Worked examples
What colour is rgb(0, 128, 255)? Convert it to its hex equivalent.
00. Decimal 128 = hexadecimal 80. Decimal 255 = hexadecimal FF.#0080FF β a medium-to-bright blue with a medium green channel at about half intensity, giving it a 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 centred white text, footer same as header, and a responsive main area that is 90% wide but no wider than 60rem.
text-align: center to align the inline text inside the header and footer boxes.main a fluid width of 90% and a max-width of 60rem, so it can shrink on smaller screens without becoming too wide on larger ones.body { background-color: #f8f8fc; } header { background-color: #185FA5; color: #ffffff; padding: 1rem; text-align: center; } footer { background-color: #185FA5; color: #ffffff; padding: 1rem; text-align: center; } main { width: 90%; max-width: 60rem; }
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. Commonly used font-style values include normal, italic, and oblique. Bold text is controlled by font-weight.text-decoration: none on links in navbars. Browsers generally underline hyperlinks β <a> elements with an href attribute β by default; an <a> without href is not a hyperlink and is not generally underlined. To create a clean navigation bar, set text-decoration: none on its hyperlinks.You should be able to recognise valid CSS colour syntax. Given a hex code like #42A5F5, you should also 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.
Know at least two ways to specify a colour in CSS (named, hex, or RGB) and be able to give a valid example of 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. Also style main with a responsive width of 90%, a maximum width of 60rem, and centred text. (5 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;
}
main {
width: 90%;
max-width: 60rem;
text-align: center;
}
1 mark per selector (correct properties with clear hierarchy β h1 larger/darker than h2, h2 larger/more prominent than p β plus the required responsive width, maximum width, and text alignment on main). Accept any reasonable typography 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 reinforces how to interpret the RRGGBB structure by reasoning about channel dominance without doing exact conversions. Emphasise recognising valid hex syntax and explaining which colour channel is strongest.