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