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