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