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