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