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