CSS Worksheet: Practice Test
Code tip (Rule, then maths): Find the topic: syntax, selectors, properties, colours, box model, cascade, flexbox or media queries. Decide which rule or property applies to the element. For sizes, write the sum down: both sides for the box model, free space for flexbox.
NameDateTime takenScore ___ / 40
-
1.🖌️ What colour is behind the letters?
h1 {
font-size: 36px;
text-align: left;
color: black;
background-color: blue;
} (a) blue (b) purple (c) black -
2.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 320px;
justify-content: center;
}
Inside are 2 boxes, each 100px wide (no margins). - 3.True or false: .menu is a class selector. (a) False (b) True
-
4.⚖️ What colour is the text of this element?
<p class="red" id="logo">Hi</p>
CSS:
.red { color: yellow; }
.red { color: green; } (a) yellow (b) black (c) green (d) orange -
5.🎯 Which CSS selector matches this element?
<h2 class="note" id="intro">Hello</h2> (a) .big (b) .intro (c) #main (d) .note -
6.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 140px;
justify-content: flex-start;
}
Inside are 2 boxes, each 60px wide (no margins). - 7.🎯 Which sign starts an id selector? (a) . (b) & (c) # (d) @
-
8.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 120px;
justify-content: center;
}
Inside are 2 boxes, each 50px wide (no margins). - 9.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) neither (c) the shorter one (d) the later one
- 10.What does justify-content: center do? (a) puts boxes in the middle (b) equal gaps, none at ends (c) packs boxes at the end (d) packs boxes at the start
- 11.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
-
12.✍️ How many declarations (property: value pairs) are in this rule?
li {
margin: 10px;
font-size: 20px;
background-color: yellow;
} - 13.True or false: margin is the gap round content. (a) False (b) True
- 14.True or false: padding is the gap round content. (a) False (b) True
-
15.🖌️ What colour are the letters?
p {
background-color: white;
font-size: 28px;
text-align: center;
color: purple;
} (a) white (b) red (c) purple - 16.True or false: .menu is an element selector. (a) False (b) True
- 17.🧩 Which language makes headings and lists? (a) CSS (b) JavaScript (c) HTML
- 18.✍️ Which sign goes between a property and its value? (a) ; (b) = (c) : (d) -
- 19.What does justify-content: space-between do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the end (d) packs boxes at the start
-
20.🖌️ Where does the text sit on its line?
h2 {
color: black;
background-color: red;
text-align: center;
font-size: 12px;
} (a) on the left (b) in the middle (c) on the right -
21.✍️ How many declarations (property: value pairs) are in this rule?
#top {
font-weight: bold;
} -
22.⚖️ What colour is the text of this element?
<h2 class="menu" id="logo">Hi</h2>
CSS:
.menu { color: green; }
.menu { color: blue; } (a) yellow (b) blue (c) red (d) green -
23.✍️ What value is given to background-color in this rule?
h2 {
margin: 10px;
font-weight: bold;
background-color: yellow;
} (a) 10px (b) 8px (c) background-color (d) yellow -
24.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 22px;
}
} (a) No (b) Yes - 25.🖌️ Which CSS property sets the letter colour? (a) font-weight (b) color (c) background-color (d) font-family
- 26.🎯 Which element does the selector h2 style? (a) <div class="big"> (b) <h2 class="big"> (c) <span id="intro"> (d) <li>
- 27.🌈 Which colour is #ffffff? (a) blue (b) cyan (c) red (d) white
-
28.🖌️ What colour are the letters?
li {
background-color: black;
font-size: 40px;
color: orange;
text-align: left;
} (a) black (b) yellow (c) orange -
29.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 220px;
justify-content: flex-end;
}
Inside are 2 boxes, each 100px wide (no margins). - 30.🌈 In #4c0000 the red part is the hex number 4c. What is it as a normal number?
- 31.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) red (c) black (d) blue
-
32.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 10px;
}
} (a) No (b) Yes -
33.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 320px;
justify-content: center;
}
Inside are 4 boxes, each 50px wide (no margins). -
34.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 28px;
}
} -
35.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 220px;
padding: 20px;
border: 4px solid black;
margin: 15px;
} -
36.🖌️ How big is the text, in px?
h1 {
color: orange;
background-color: green;
font-size: 32px;
text-align: left;
} - 37.💪 Which flexbox property lines boxes up across? (a) justify-content (b) align-items (c) flex-direction (d) gap
-
38.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 170px;
justify-content: flex-end;
}
Inside are 3 boxes, each 40px wide (no margins). - 39.🖌️ Which CSS property picks the font style? (a) font-family (b) font-weight (c) background-color (d) font-size
- 40.🌈 Which hex code is blue? (a) #0000ff (b) #ffff00 (c) #00ff00 (d) #ff00ff
Answer key
- blue
- 60
- True
- green
- .note
- 20
- #
- 10
- the later one
- puts boxes in the middle
- an element selector
- 3
- False
- True
- purple
- False
- HTML
- :
- equal gaps, none at ends
- in the middle
- 1
- blue
- yellow
- No
- color
- <h2 class="big">
- white
- orange
- 20
- 76
- red
- Yes
- 60
- 20
- 268
- 32
- align-items
- 50
- font-family
- #0000ff
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids