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