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