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