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