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.
What students will learn in this module
Every question in Module 34
Quick questions
- Which part of a CSS rule chooses the elements to style?AThe declaration blockBThe selector
- What separates a property from its value?AA colon, as in color: redBA semicolon, as in color; red
- What ends each declaration?AA semicolonBA comma
- Which symbols wrap the declarations in a rule?ACurly braces { }BRound brackets ( )
- 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 doescolorMatch it to what it doesThe setting given to the propertyMatch it to what it doesWrap the declarations of one ruleMatch it to what it doescolor blue;Match it to what it doesp ( color: red; )Match it to what it doesFill in the blanks
__ { color: red; }Hint: Type the selector that targets every h1 element
p { ______ blue; }Hint: Type the property name color followed by a colon
p { color: _____ margin: 0; }Hint: Type the value blue followed by the semicolon that ends the declaration
______ margin: 0; }
Hint: Type the selector body, a space, then the opening curly brace
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}
