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.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 600px) {
p {
font-size: 22px;
}
} (a) Yes (b) No - 2.True or false: .big is an id selector. (a) True (b) False
- 3.What does justify-content: space-between do? (a) packs boxes at the end (b) packs boxes at the start (c) equal gaps, none at ends (d) puts boxes in the middle
- 4.🔍 Which is the odd one out? (a) adds space around boxes (b) makes a link (c) puts a picture on a page (d) gives the page structure
- 5.📦 In the box model, which part is the text or picture? (a) margin (b) padding (c) border (d) content
-
6.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 22px;
}
} (a) No (b) Yes -
7.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 14px;
}
} -
8.🖌️ Where does the text sit on its line?
h1 {
font-size: 12px;
background-color: yellow;
text-align: right;
color: purple;
} (a) on the left (b) on the right (c) in the middle -
9.🖌️ What colour is behind the letters?
li {
background-color: white;
font-size: 20px;
text-align: center;
color: purple;
} (a) blue (b) purple (c) white - 10.🌈 In #005600 the green part is the hex number 56. What is it as a normal number?
-
11.⚖️ What colour is the text of this element?
<p class="star" id="hero">Hi</p>
CSS:
.star { color: white; }
.star { color: purple; } (a) white (b) orange (c) purple (d) black - 12.💪 Which justify-content value packs boxes at the end? (a) center (b) flex-end (c) space-between (d) flex-start
- 13.💪 Which flexbox property lines boxes up across? (a) align-items (b) flex-direction (c) justify-content (d) gap
-
14.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 60px;
padding: 15px;
border: 4px solid black;
margin: 5px;
} -
15.⚖️ What colour is the text of this element?
<h2 class="menu" id="hero">Hi</h2>
CSS:
h2 { color: orange; }
h2 { color: red; } (a) black (b) red (c) green (d) orange - 16.🧩 Which language gives the page structure? (a) HTML (b) JavaScript (c) CSS
- 17.Which of these does CSS do? (a) lays out the page (b) counts down a timer (c) checks a quiz answer (d) shows a pop-up message
- 18.🔍 Which is the odd one out? (a) sets colours and fonts (b) adds space around boxes (c) changes the text size (d) counts down a timer
- 19.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) blue (c) red (d) black
-
20.📦 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: 30px;
border: 4px solid black;
margin: 5px;
} - 21.What does justify-content: flex-start do? (a) equal gaps, none at ends (b) packs boxes at the end (c) packs boxes at the start (d) puts boxes in the middle
- 22.True or false: JavaScript changes the page live. (a) False (b) True
- 23.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
- 24.🔍 Which is the odd one out? (a) shows a pop-up message (b) lays out the page (c) adds space around boxes (d) rounds box corners
-
25.🎯 Which CSS selector matches this element?
<h1 class="star" id="intro">Hello</h1> (a) #main (b) .intro (c) .star (d) #star -
26.⚖️ What colour is the text of this element?
<p class="note" id="top">Hi</p>
CSS:
.note { color: green; }
p { color: red; }
#top { color: white; } (a) yellow (b) white (c) green (d) red -
27.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 20px;
}
} (a) No (b) Yes - 28.🎯 Can many elements share the same class? (a) Yes (b) No
-
29.🎯 Which CSS selector matches this element?
<li class="menu" id="intro">Hello</li> (a) #main (b) li (c) .note (d) #menu -
30.⚖️ What colour is the text of this element?
<h2 class="menu" id="intro">Hi</h2>
CSS:
#intro { color: blue; }
.menu { color: white; }
h2 { color: red; } (a) blue (b) red (c) white (d) black -
31.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} - 32.💪 Which flexbox property turns on flexbox? (a) gap (b) justify-content (c) display: flex (d) align-items
- 33.✍️ Which sign ends each CSS declaration? (a) . (b) ; (c) , (d) :
- 34.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) white (c) blue (d) green
-
35.✍️ How many declarations (property: value pairs) are in this rule?
body {
font-size: 20px;
background-color: yellow;
border: 2px solid;
color: red;
} -
36.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 160px;
justify-content: center;
}
Inside are 3 boxes, each 40px wide (no margins). -
37.⚖️ What colour is the text of this element?
<p class="big" id="hero">Hi</p>
CSS:
p { color: orange; }
p { color: green; } (a) yellow (b) orange (c) green (d) blue -
38.🎯 Which CSS selector matches this element?
<li class="red" id="logo">Hello</li> (a) .logo (b) #end (c) #logo (d) #red -
39.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 350px;
justify-content: space-between;
}
Inside are 4 boxes, each 50px wide (no margins). -
40.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 22px;
}
}
Answer key
- No
- False
- equal gaps, none at ends
- adds space around boxes
- content
- No
- 12
- on the right
- white
- 86
- purple
- flex-end
- align-items
- 108
- red
- HTML
- lays out the page
- counts down a timer
- red
- 288
- packs boxes at the start
- True
- an element selector
- shows a pop-up message
- .star
- white
- No
- Yes
- li
- blue
- 24
- display: flex
- ;
- blue
- 4
- 20
- green
- #logo
- 50
- 20
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids