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