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