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