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