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