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