Comm-101COMM-101 ESSENTIALS OF DIGITAL MEDIA
Challenge 2 of 3 — Reading CSS
← Home
Builds on Challenge 1

Reading CSS for the first time

The Riverhawk Rockets' HTML page works — but it looks pretty plain. CSS is what makes websites look designed. Let's learn how it works.

Part 1 — the big idea

What is CSS — and why do we need it?

HTML describes what things are. CSS describes how they look. Without CSS, every website looks like a plain text document. With CSS you control color, size, spacing, and fonts — everything visual.

CSS works through rules. A rule has two parts: a selector (who gets styled) and declarations (what the style is).

h1 { color: #cc0000; font-size: 36px; }
h1 — the selector: "Target every h1 tag on the page"
color — the property: "Which thing do you want to change?"
#cc0000 — the value: "Change it to this"
Everything inside { } is called a declaration block

In this CSS rule, what does h1 tell the browser?

Part 2 — element selectors

Styling by tag name

The simplest selector is just the tag name. Write p and you style every paragraph. Write h2 and you style every h2 — all at once with one rule.

CSS
h1 { color: #cc0000; } p { font-size: 15px; color: #444444; } a { color: #0055cc; }
Result in browser
Riverhawk Rockets
Your hometown soccer team since 1994.
Buy Tickets
Notice how one CSS rule changes every matching tag. If the page had ten paragraphs, one p rule would style all ten at once.
Try it yourself: Imagine adding three more paragraphs. Which CSS rule would affect all of them at once?

If you add a second <p> tag to the page, what happens to it?

Part 3 — classes

Targeting specific elements with classes

Element selectors style every matching tag. But what if you want to style just one paragraph differently? That's what classes are for. You add a class attribute in HTML, then target it in CSS with a dot.

HTML
<p>Regular paragraph.</p> <p class="highlight"> Next match: Saturday! </p>
CSS
p { color: #444; } .highlight { background: #fff3cd; font-weight: bold; }
Live preview

Regular paragraph.

Next match: Saturday!

The dot in .highlight is CSS saying "look for a class called highlight." In HTML you write class="highlight" — no dot needed there.
Try it yourself: Compare these three selector types before answering the question below.
h1Element selector: styles every matching tag.
.highlightClass selector: reusable style for selected elements.
#scoreboardID selector: one unique element on the page.

You want to style three specific list items in red, but leave the others alone. What's the best approach?

Part 4 — IDs

One-of-a-kind elements with IDs

A class can be reused on many elements. An ID is for one unique element only — like the main scoreboard. You add id="..." in HTML and target it in CSS with a #.

HTML
<div id="scoreboard"> Rockets 3 – City FC 1 </div>
CSS
#scoreboard { background: #111; color: #ffffff; font-size: 24px; padding: 16px; }
Live preview
Rockets 3 – City FC 1
h1, p, a
Element selector — styles every matching tag
.highlight
Class selector — reusable, targets elements with that class
#scoreboard
ID selector — targets one unique element only
Try it yourself: Decide whether the scoreboard should be reusable or one-of-a-kind before choosing a selector.

The Rockets page has one special announcement banner that appears nowhere else. Which selector fits best?

Part 5 — connecting CSS to HTML

Where does CSS actually go?

CSS usually lives in a separate .css file. You connect it to your HTML page using a <link> tag inside the <head>.

<html> <head> <title>Riverhawk Rockets</title> <link rel="stylesheet" href="rockets.css"> </head> <body> ... </body> </html>
rel="stylesheet" — tells the browser what kind of file this is
href="rockets.css" — the filename of your CSS file
This tag goes in <head> so styles load before the content appears.

Why does the <link> tag go inside <head> rather than <body>?

Part 6 — putting it together

Read the full Rockets stylesheet

Here's a complete CSS file for the Rockets page. Click each rule to toggle it on and off — watch exactly what changes in the preview below.

Rockets page — live preview
Riverhawk Rockets
HomeSchedulePlayersShop

Your hometown soccer team since 1994. Come cheer us on every Saturday.

Next match: Saturday vs. City FC at 2pm!

Rockets 3 – City FC 1

When you turn off the .highlight rule, which element loses its styling?

Results

What you learned:
CSS rules = selector + declaration block  ·  Element selectors (p, h1) style every matching tag  ·  Class selectors (.name) style reusable groups  ·  ID selectors (#name) style one unique element  ·  CSS links to HTML via <link> in <head>

Next Challenge

Move into modern site structure, error fixing, and responsive design.

Challenge 3 — Modern Web Concepts →