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