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