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