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