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