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