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