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