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