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