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