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