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