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