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