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