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