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