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