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