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