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