CSS Worksheet: CSS Rules and Syntax
Code tip (Colon in the middle, semicolon at the end): A rule is: selector { property: value; property: value; } The property is before the colon, the value after it; a semicolon ends each declaration. Count the property: value; lines to count the declarations.
NameDateTime takenScore ___ / 40
- 1.✍️ In color: blue; which part is the property? (a) blue (b) : (c) color (d) ;
-
2.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
padding: 8px;
} -
3.✍️ What is the selector in this CSS rule?
li {
font-style: italic;
font-size: 20px;
margin: 10px;
font-weight: bold;
} (a) body (b) 20px (c) li (d) font-style -
4.✍️ What is the selector in this CSS rule?
.box {
color: red;
background-color: yellow;
border: 2px solid;
text-align: center;
} (a) h2 (b) .box (c) yellow (d) color - 5.✍️ CSS declarations go inside which brackets? (a) ( ) (b) < > (c) [ ] (d) { }
- 6.✍️ Which sign ends each CSS declaration? (a) . (b) : (c) ; (d) ,
-
7.✍️ How many declarations (property: value pairs) are in this rule?
.note {
width: 300px;
color: red;
font-style: italic;
} -
8.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-style: italic;
background-color: yellow;
text-align: center;
margin: 10px;
} - 9.✍️ Which sign goes between a property and its value? (a) ; (b) = (c) : (d) -
-
10.✍️ Which property is set to center in this rule?
h1 {
text-align: center;
color: red;
background-color: yellow;
} (a) margin (b) center (c) background-color (d) text-align -
11.✍️ How many declarations (property: value pairs) are in this rule?
.box {
padding: 8px;
background-color: yellow;
font-size: 20px;
margin: 10px;
} -
12.✍️ What is the selector in this CSS rule?
h1 {
background-color: yellow;
font-style: italic;
font-size: 20px;
} (a) h1 (b) p (c) italic (d) background-color -
13.✍️ What value is given to font-weight in this rule?
.box {
margin: 10px;
font-size: 20px;
text-align: center;
font-weight: bold;
} (a) font-weight (b) 2px solid (c) bold (d) 300px -
14.✍️ What is the selector in this CSS rule?
#top {
padding: 8px;
background-color: yellow;
} (a) #top (b) li (c) padding (d) yellow - 15.✍️ How does a CSS comment start? (a) # (b) // (c) <!-- (d) /*
-
16.✍️ Which property is set to 8px in this rule?
h1 {
border: 2px solid;
font-style: italic;
width: 300px;
padding: 8px;
} (a) border (b) font-weight (c) padding (d) 8px -
17.✍️ What is the selector in this CSS rule?
h2 {
text-align: center;
font-size: 20px;
} (a) text-align (b) h2 (c) h1 (d) 20px -
18.✍️ What value is given to width in this rule?
h1 {
font-size: 20px;
width: 300px;
margin: 10px;
} (a) width (b) italic (c) red (d) 300px -
19.✍️ What is the selector in this CSS rule?
.box {
text-align: center;
width: 300px;
} (a) text-align (b) 300px (c) h2 (d) .box -
20.✍️ What is the selector in this CSS rule?
li {
margin: 10px;
background-color: yellow;
padding: 8px;
width: 300px;
} (a) yellow (b) li (c) body (d) margin -
21.✍️ What value is given to border in this rule?
h2 {
border: 2px solid;
width: 300px;
} (a) 300px (b) border (c) 2px solid (d) italic -
22.✍️ Which property is set to 300px in this rule?
li {
background-color: yellow;
color: red;
width: 300px;
font-size: 20px;
} (a) font-style (b) color (c) 300px (d) width -
23.✍️ What is the selector in this CSS rule?
#top {
color: red;
margin: 10px;
} (a) #top (b) 10px (c) li (d) color -
24.✍️ Which property is set to 20px in this rule?
h1 {
font-style: italic;
font-size: 20px;
} (a) 20px (b) font-size (c) background-color (d) text-align - 25.✍️ In color: blue; which part is the value? (a) blue (b) color (c) : (d) ;
-
26.✍️ What is the selector in this CSS rule?
#top {
width: 300px;
text-align: center;
font-weight: bold;
background-color: yellow;
} (a) width (b) li (c) center (d) #top -
27.✍️ What value is given to color in this rule?
h2 {
background-color: yellow;
color: red;
border: 2px solid;
} (a) center (b) 20px (c) red (d) color -
28.✍️ What value is given to background-color in this rule?
.note {
color: red;
background-color: yellow;
padding: 8px;
margin: 10px;
} (a) yellow (b) 10px (c) background-color (d) 8px -
29.✍️ How many declarations (property: value pairs) are in this rule?
body {
margin: 10px;
} -
30.✍️ Which property is set to red in this rule?
p {
color: red;
font-size: 20px;
} (a) red (b) text-align (c) color (d) font-size -
31.✍️ Which property is set to 300px in this rule?
.box {
width: 300px;
text-align: center;
padding: 8px;
font-size: 20px;
} (a) font-style (b) 300px (c) width (d) color -
32.✍️ What is the selector in this CSS rule?
#top {
font-size: 20px;
background-color: yellow;
} (a) li (b) yellow (c) #top (d) font-size -
33.✍️ What value is given to color in this rule?
.note {
border: 2px solid;
color: red;
} (a) red (b) color (c) center (d) 20px -
34.✍️ What value is given to width in this rule?
li {
text-align: center;
width: 300px;
font-size: 20px;
font-weight: bold;
} (a) red (b) 300px (c) italic (d) width -
35.✍️ Which property is set to yellow in this rule?
h1 {
background-color: yellow;
color: red;
text-align: center;
} (a) padding (b) margin (c) yellow (d) background-color -
36.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
font-style: italic;
border: 2px solid;
background-color: yellow;
width: 300px;
} -
37.✍️ What is the selector in this CSS rule?
.note {
font-weight: bold;
font-size: 20px;
border: 2px solid;
} (a) font-weight (b) #top (c) 20px (d) .note -
38.✍️ How many declarations (property: value pairs) are in this rule?
.box {
border: 2px solid;
width: 300px;
} -
39.✍️ What value is given to background-color in this rule?
h1 {
background-color: yellow;
font-size: 20px;
} (a) 10px (b) background-color (c) yellow (d) 8px -
40.✍️ What value is given to color in this rule?
h2 {
color: red;
text-align: center;
padding: 8px;
} (a) red (b) color (c) center (d) 20px
Answer key
- color
- 1
- li
- .box
- { }
- ;
- 3
- 4
- :
- text-align
- 4
- h1
- bold
- #top
- /*
- padding
- h2
- 300px
- .box
- li
- 2px solid
- width
- #top
- font-size
- blue
- #top
- red
- yellow
- 1
- color
- width
- #top
- red
- 300px
- background-color
- 4
- .note
- 2
- yellow
- red
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids