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