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