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