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