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