Your site says the right things. Today you decide how it looks: its colours, its font, the size of its text.
And today is the day you stop only reading the code and start writing it.
Getting started: open the builder below and carry on with your site.
This is the first lesson where students write code. CSS is a gentle place to start: no closing tags to mismatch, and a typo usually spoils one rule rather than the whole page. Expect typos and treat them as the lesson, not an interruption.
Before anyone types, say it once: the "go back to blocks" button throws away everything you have typed.
Everything you have written so far says what things are: a heading, a paragraph, a picture. None of it says what they should look like. That is a separate job, and it has its own language: CSS.
A CSS rule has three parts worth naming, because you will use these words all lesson:
So this rule says: for the whole page, make the background pale blue.
body {
background: lightblue;
color: navy;
font-family: sans-serif;
}
Predict beat. Show the rule and ask what would change on the page if you swapped the colour value. Take two answers before you show them.
Name the parts as you go: selector, property, value. Students will need the words when a rule breaks.
Before you change anything, find your page in the CSS.
Right now that top rule looks exactly like this, because nobody has changed anything yet:
body {
background: white;
color: black;
font-family: sans-serif;
margin: 16px;
}This is the beat the whole unit has been building to, so give it room: the blocks were never doing anything except writing this. Change a colour on the board and let them watch the CSS line change with it.
If a student cannot find the rule, it is at the very top of the CSS tab. The rules further down are the ones that make buttons look like buttons; they did not write those.
Now change it, keeping one eye on that top rule.
Before you go on: point at the top rule and say which property you changed: background, color, or font-family.
This is the block those three dropdowns live on:
{"blocks": {"languageVersion": 0, "blocks": [{"type": "web_page", "fields": {"NAME": "Home", "BG": "white", "FG": "black", "FONT": "sans-serif"}, "inputs": {"CONTENT": {"block": {"type": "wp_heading", "fields": {"TEXT": "My page", "ALIGN": "left"}}}}, "x": 10, "y": 10}]}}
This is the beat the whole unit has been building to, so give it room: the blocks were never doing anything except writing this rule. Change a colour on the board and let the class watch the line change with it.
Everyone will end up with a different colour, which is the point — the rule is theirs, not an example. Nobody needs to touch the rules further down the sheet.
Now a style that belongs to one kind of thing rather than the whole page.
Here is the block you changed, and the rule it wrote. The dot at the front means “anything labelled big”:
{"blocks": {"languageVersion": 0, "blocks": [{"type": "wp_text", "fields": {"TEXT": "This is the first thing I want people to read.", "SIZE": "big", "ALIGN": "left"}, "x": 10, "y": 10}]}}
.big {
font-size: 1.5rem;
}The pay-off is the second paragraph: one rule serving two things is exactly why CSS exists, and it is much easier to see than to explain.
Do not go deep on classes. "The class is the label; the rule finds everything wearing it" is enough for today.
You're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.