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