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