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