HTML and CSS · lesson 12 of 30 · free

CSS rules: selector, property, value — HTML and CSS for kids

A CSS rule has a selector, which says what to style, and a block in curly brackets with declarations. Each declaration is a property and a value separated by a colon and ended with a semicolon — for example the colour property set to blue. One rule can hold many declarations. CSS comments are written between a slash-star and a star-slash.

▶ Watch how it works

Got it? Practise ↓

Code tip

Colon in the middle, semicolon at the end — “each declaration is property: value;”

  1. A rule is: selector { property: value; property: value; }
  2. The property is before the colon, the value after it; a semicolon ends each declaration.
  3. Count the property: value; lines to count the declarations.

Use it for: Writing and reading CSS, and finding typing mistakes in a style sheet.

Worked example: ✍️ How many declarations (property: value pairs) are in this rule?
body {
  background-color: yellow;
  margin: 10px;
  border: 2px solid;
} → 3

  1. Each “property: value;” is one declaration.
  2. background-color, margin and border: 3 declarations.

Check: Three semicolons, three declarations ✓

▶ Watch it animated

✏️ Practice

Work it out in your head or on paper, type the answer and press Check. Stuck? Press “Show me how”.

Right: 0 · Tried: 0

🏁 Lesson 12 test

20 questions. Check each answer, then go to the next one. Get 16 or more right to pass.

🏅 Sign in with Google to earn the ✍️ CSS Rule Writer badge when you pass — and a certificate when you finish all 10 lessons of Part 2 · CSS. You can still take the test without signing in.

🖨️ CSS Worksheet: CSS Rules and Syntax

✨ Free AI tutor

Ask the AI tutor about this lesson

Why does it work? When should you use it? Ask in English, मराठी or हिंदी.

Sign in with Google to ask Free — 20 questions a day.

👩‍🏫 HTML and CSS classes near you — online or at home

Prefer a real teacher? TalentJR teachers take live online classes anywhere in India and visit homes in selected cities. Tell us what you need and our team will call you with timings and fees.

Live online classesSmall groups or 1:1 with a teacher, from home, any city.
Teacher at homeA TalentJR teacher visits your home (selected cities).
At a centreClasses at a TalentJR partner centre near you, where available.
Badges, certificates & gifts A badge for every lesson you pass, a certificate for every part you finish, plus TalentJR Points for daily practice. Computer worksheets Flowcharts, block coding, spreadsheets and safe internet.