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