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