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