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