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