Skip to main content
๐ŸŽจ CSS Basics

Anatomy of a Rule ๐Ÿ”Ž

Before you write any CSS, let's read one slowly. Every CSS rule has the same four parts, every single time:

h1 { color: blue; }

Let's name them:

  • h1 is the selector โ€” which elements to style (here, every <h1>).
  • color is the property โ€” what you want to change (the text color).
  • blue is the value โ€” how you want it (blue!).
  • The { } curly braces hold the property and value together, and the : and ; are the punctuation: property: value;.

Read it out loud like a sentence: "For every h1, set the color to blue." ๐Ÿ—ฃ๏ธ

Once you can spot these four parts, you can read any CSS rule. Try it below. ๐Ÿ‘‡

In p { font-size: 24px; }, what is the selector?

In p { font-size: 24px; }, what is the property (what you're changing)?

In p { font-size: 24px; }, what is the value?

Which punctuation goes between the property and value?