Coding Lesson
CSS: Appearance
Colours and fonts
Your goal: Style your existing hobby page.
Learn
CSS changes the presentation of your existing HTML. You will choose a light background, dark text and a readable font, then check the result. Keep the words and heading structure of your hobby page while changing how the browser displays them.
Walkthrough: why the code works
Choose which page to style
Use Open HTML file to load your downloaded hobby page, or practise with this lesson’s short starter. Find style inside head. Put CSS rules between its opening and closing tags. The body content stays outside that style block.
Read a rule one part at a time
body is the selector: it chooses the page body. Curly braces hold declarations. Each declaration has a property, a colon and a value; semicolons separate declarations. The starter sets a white background and black text. Change one value, run the code, and observe the effect.
body { background-color: lightblue; color: #172554; font-family: Arial, sans-serif; }Understand what each property changes
background-color fills the body background. color sets text colour inherited by many child elements unless another rule overrides it. font-family chooses a font: Arial is tried first and sans-serif supplies a fallback. It is normal for the fallback’s exact appearance to differ across devices.
Keep reading comfortable
Choose text that remains distinct from the background. Dark blue on a light background is a useful starting point, but not every dark-looking combination has sufficient contrast. Keep links recognisable as links. You can add font-size: 1rem and line-height: 1.6 to body for a readable baseline without fixing the page’s height.
Compare before and after
Read a full paragraph, not just the title. Narrow the browser and try zooming in. Text should wrap and remain readable. If you cannot see a change, check whether you edited the rule for the intended element. Download your styled version when you are satisfied.
Expected results
The sample rule produces a light-blue page with dark-blue text and a sans-serif font.
Headings remain headings and paragraphs remain paragraphs; their content is unchanged.
Text stays readable at a narrow window size and when zoomed in.
Common mistakes and how to fix them
CSS is displayed as text: Place the rules inside style in head, rather than typing them as ordinary body text.
A declaration is ignored: Check its property spelling, colon, value and semicolon. Keep both opening and closing curly braces.
Only some text changes: A more specific or later rule may set its own colour or font. Inspect the affected element before changing unrelated rules.
View starter code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My hobby page</title>
<style>
body {
background-color: white;
color: black;
}
</style>
</head>
<body>
<h1>My hobby</h1>
<p>I enjoy learning something new.</p>
</body>
</html>Your challenge
Use your saved hobby page or this starter. Set a light background, dark text and a readable font.
Keep developing your hobby page: Download HTML before leaving the sandbox, then choose Open HTML file when returning to your project. Load saved draft restores only this lesson’s draft in this browser.
Practise in the sandboxShow a hint
Inside style, try body { background-color: lightblue; color: #172554; font-family: Arial, sans-serif; }.
Show a sample answer
Try the challenge first. This is one possible answer or a snippet to adapt.
body {
background-color: lightblue;
color: #172554;
font-family: Arial, sans-serif;
}Check your work
All text remains easy to read against its background.
Completion is your own check, not an automatic grade.
