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