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