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