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