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