CSS rule syntax, online

Six activities your students do on their own devices. See who's finished, and their scores.

CSS rule syntax in one minute

What students need to know

The value comes after the colon and says how the property should look. Curly braces open and close the declaration block.

The selector comes first, before the curly braces, and says which elements the rule applies to. The semicolon tells the browser where one declaration stops and the next begins.

Mistakes students make

  • The colon is missing between the property and the value. It should be color: red; because every declaration needs a colon.
  • The color declaration has no semicolon. It should be color: blue; so the browser knows where it ends.
  • The opening curly brace is missing after the selector. It should be p { so the declaration block has a start.
  • The block opens with a round bracket. It should be body { because declaration blocks use curly braces.

Discover other journeys with this module

What students will learn in this module

Every question in Module 34

Quick questions

  1. Which part of a CSS rule chooses the elements to style?AThe declaration blockBThe selector
  2. What separates a property from its value?AA colon, as in color: redBA semicolon, as in color; red
  3. What ends each declaration?AA semicolonBA comma
  4. Which symbols wrap the declarations in a rule?ACurly braces { }BRound brackets ( )
  5. Which is a complete, correct declaration?Acolor = blue;Bcolor: blue;

Key terms

Students type the meaning of:

  • selector { property: value; }

Match the pairs

pMatch it to what it does
colorMatch it to what it does
The setting given to the propertyMatch it to what it does
Wrap the declarations of one ruleMatch it to what it does
color blue;Match it to what it does
p ( color: red; )Match it to what it does

Fill in the blanks

  1. __ {
      color: red;
    }

    Hint: Type the selector that targets every h1 element

  2. p {
      ______ blue;
    }

    Hint: Type the property name color followed by a colon

  3. p {
      color: _____
      margin: 0;
    }

    Hint: Type the value blue followed by the semicolon that ends the declaration

  4. ______
      margin: 0;
    }

    Hint: Type the selector body, a space, then the opening curly brace

  5. a {
      color: green;
      ________________
    }

    Hint: Type the declaration font-size: 18px; including the colon and semicolon

Spot the error

Question 1

Ap {B  color red;C}

Question 2

Ah1 {B  color: blueC  font-size: 2rem;D}

Question 3

ApB  color: red;C}

Question 4

Abody (B  margin: 0;C}

Question 5

Ap {B  color; red;C}