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