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