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