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