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