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