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