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