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