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