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