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