Write a CSS rule that styles every tag of one kind, and find out that it changes how they look, not what they are.
Every website you know uses the same HTML tags; CSS is what makes one look nothing like another.
HTML says what each part of a page is. CSS says how it looks. CSS rules go in a <style> block, which sits at the top of the code for now; a later lesson shows where it goes in a whole page.
Make your prediction first. Help opens once you've locked it in.
<style>
p {
color: teal;
}
</style>
<h1>Sports day</h1>
<p>Sports day is on Friday.</p>
<h2>What to bring</h2>
<p>Bring a hat and water.</p>
p { color: teal; } is a rule. Read the code. How many lines of text will turn teal?
Compare the page with your prediction. Then change p to h2 and watch the colour move. Add font-size: 28px; on a new line under color: teal;.
| Code | What it does | Why |
|---|---|---|
<style> … </style> |
Holds the rules | The browser reads the rules between these tags and does not show them. For now the block sits at the top |
p { |
The selector: which tag the rule is for | It names a kind of tag, so every <p> changes, not just the first. The { opens the rule |
color: teal; |
A property, a colon, a value and a semicolon | color is the text colour. Colours can be names such as teal, navy or crimson. The ; ends the line |
font-size: 28px; |
Sets how big the text is | px is the unit. Other properties: font-family: sans-serif;, background-color: lightyellow;, text-align: center; |
} |
Closes the rule | A rule can hold as many property lines as you like |
the <h1> and <h2> lines |
Stay as they were | The rule names p only, and the HTML did not change |
<style>
p {
color: teal;
}
</style>
<h1>Sports day</h1>
<p>Sports day is on Friday.</p>
<h2>What to bring</h2>
<p>Bring a hat and water.</p>
<style>
p {
color: teal;
}
</style>
<h1>Sports day</h1>
<p>Sports day is on Friday.</p>
<h2>What to bring</h2>
<p>Bring a hat and water.</p>
<p>Races start at 9 am.</p>
A new paragraph appears at the end of the page. Which lines does the rule colour?
Look at the rule for h1.
A third paragraph is added to the page. Fill in the colour of each line of text.
| text | tag | colour |
|---|---|---|
| Sports day | h1 | black |
| Sports day is on Friday. | p | teal |
| What to bring | h2 | |
| Bring a hat and water. | p | |
| Races start at 9 am. | p |
Give the heading a different colour.
Change only the value after color:, and keep the semicolon.

Add a rule that makes every paragraph 20px.
Add a new rule inside the <style> block, below the h1 rule.
p { font-size: 20px; }

Add a rule that gives every h2 a lightyellow background and centred text.
A new rule needs a selector, braces and property lines: h2 { ... }
Two property lines in one rule: background-color and text-align.

Add a line to the p rule so the paragraphs use font-family: sans-serif;.
Add a line inside the p rule, under font-size. Every property line ends with a semicolon.

Add a rule that makes the paragraphs 20px.
This ticks when your page has all of the above.
Add a rule that gives the h2 headings a lightyellow background and centred text.
This ticks when your page has all of the above.
Make the paragraphs use font-family: sans-serif.
This ticks when your page has all of the above.
Sam's notice should have important words in crimson, but the page looks wrong. Fix the tags, then write one rule so every <strong> is crimson.
<style>
h1 {
color: navy;
}
</style>
<h1>Sports day</h1>
<p>Bring <strong>a hat and <em>water</strong></em> on Friday.</p>
<p>Races start at <strong>9 am</strong>.</p>

Fix the tags so they nest, then add one rule that colours all the important words.
This ticks when your page has all of the above.
The <style> block is ready at the top of this concert notice, with no rules. Write three rules: one for h1, one for h2 and one for p. Give each a colour, and change at least one font.
Start with the rule for h1, then add one rule at a time. Check the page after each.
Each rule is a selector, braces, and property lines ending in semicolons.

Style the concert notice with a rule for h1, one for h2 and one for p.
This ticks when your page has all of the above.
Students write CSS rules in a style block, find out that a tag selector styles every tag of that kind, and that a rule changes how a part looks, not what it is. About 50 minutes.
Open the teacher guide: answers, solutions, slides and a worksheet.
Read the unit primer "HTML structure in 5 minutes" (the CSS section) first, then do the Make task yourself.
New words: a rule is a selector followed by property lines in braces, p { color: teal; }. The selector (p) names a kind of tag; each line is a property, a colon, a value and a semicolon. Colours here are names such as teal and crimson. The <style> block sits at the top of the code for now; where it goes in a whole page comes later.
Link to the three layers idea from Digital systems: the words are content, the tags are structure, the rules are presentation.
Believing a rule picks one element. Ask which tag the selector names, and how many of that tag are on the page, before you say.
Stretch: Try font-size: 12px on the h1 and 60px on the p. Then ask whether the h1 is still a heading, and how a screen reader would know.
Support: Give students the Modify starter and do the second task together on the board: the selector, the braces, then one property line.
Next lesson is lists: a rule for li styles every item at once. Later, classes let you pick only some tags of a kind. Class idea: restyle the same page three ways (calm, loud, sporty) without changing the HTML.