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