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