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