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