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