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