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.🎯 Which element does the selector h2 style? (a) <div class="box"> (b) <li> (c) <h2 class="box"> (d) <span id="main">
- 2.🌈 In #002300 the green part is the hex number 23. What is it as a normal number?
- 3.Which of these is padding? (a) the line round the box (b) the gap round content (c) the text or picture (d) space outside the border
- 4.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) exactly 1000px (c) 600px or wider (d) 600px or narrower
- 5.📦 In the box model, which part is space inside the border? (a) content (b) margin (c) padding (d) border
-
6.✍️ What value is given to font-size in this rule?
body {
color: red;
font-size: 20px;
border: 2px solid;
} (a) 20px (b) center (c) font-size (d) yellow -
7.✍️ What is the selector in this CSS rule?
.box {
font-size: 20px;
color: red;
} (a) font-size (b) .box (c) h2 (d) red - 8.💪 Which flexbox property spaces boxes along a row? (a) gap (b) flex-direction (c) justify-content (d) display: flex
- 9.🌈 Which colour of light is strongest in rgb(36, 190, 114)? (a) green (b) red (c) blue
-
10.💪 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). -
11.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 70px;
padding: 15px;
border: 3px solid black;
margin: 15px;
} - 12.🖌️ Which CSS property makes the text bold? (a) font-family (b) font-weight (c) text-align (d) color
-
13.⚖️ What colour is the text of this element?
<h1 class="note" id="top">Hi</h1>
CSS:
.note { color: red; }
.note { color: white; } (a) purple (b) green (c) white (d) red -
14.✍️ Which property is set to 300px in this rule?
#top {
font-style: italic;
width: 300px;
} (a) width (b) color (c) font-style (d) 300px -
15.⚖️ What colour is the text of this element?
<h1 class="big" id="top">Hi</h1>
CSS:
.big { color: green; }
#top { color: red; }
h1 { color: white; } (a) red (b) green (c) white (d) orange -
16.✍️ What is the selector in this CSS rule?
#top {
width: 300px;
font-size: 20px;
padding: 8px;
border: 2px solid;
} (a) width (b) 20px (c) li (d) #top -
17.✍️ How many declarations (property: value pairs) are in this rule?
.note {
width: 300px;
margin: 10px;
} - 18.🧩 Which language gives the page structure? (a) CSS (b) HTML (c) JavaScript
- 19.📦 In the box model, which part is space outside the border? (a) padding (b) margin (c) content (d) border
- 20.What does justify-content: space-between 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
- 21.🎯 Which element does the selector p style? (a) <li id="intro"> (b) <p class="menu"> (c) <h2 class="menu"> (d) <h1>
- 22.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) display: flex (c) align-items (d) justify-content
- 23.True or false: li is an element selector. (a) True (b) False
- 24.🌈 Which colour is #ffffff? (a) yellow (b) magenta (c) white (d) red
- 25.True or false: .star is an id selector. (a) True (b) False
-
26.🎯 Which CSS selector matches this element?
<li class="note" id="end">Hello</li> (a) .end (b) #end (c) #hero (d) #note -
27.🖌️ Where does the text sit on its line?
h1 {
font-size: 28px;
text-align: center;
color: green;
background-color: blue;
} (a) in the middle (b) on the left (c) on the right - 28.🔍 Which is the odd one out? (a) shows a pop-up message (b) makes a form box (c) checks a quiz answer (d) reacts to a button click
- 29.🎯 Which element does the selector div style? (a) <p class="star"> (b) <span> (c) <h1 id="main"> (d) <div class="star">
-
30.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 8px;
}
} -
31.🎯 Which CSS selector matches this element?
<h1 class="menu" id="main">Hello</h1> (a) .main (b) #logo (c) h1 (d) .note -
32.✍️ How many declarations (property: value pairs) are in this rule?
p {
width: 300px;
font-style: italic;
margin: 10px;
background-color: yellow;
} - 33.📱 What does a media query check? (a) the time of day (b) the page title (c) the battery level (d) the screen width
- 34.🎯 Which element does the selector #hero style? (a) <h1 id="hero"> (b) <h1 id="top"> (c) <h2 class="star"> (d) <h1 class="hero">
-
35.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 360px;
justify-content: center;
}
Inside are 4 boxes, each 50px wide (no margins). - 36.💪 Which justify-content value packs boxes at the end? (a) flex-start (b) flex-end (c) center (d) space-between
-
37.✍️ How many declarations (property: value pairs) are in this rule?
.box {
width: 300px;
color: red;
text-align: center;
font-weight: bold;
} -
38.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 24px;
}
} -
39.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 600px) {
p {
font-size: 22px;
}
} (a) Yes (b) No -
40.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 170px;
justify-content: space-between;
}
Inside are 2 boxes, each 50px wide (no margins).
Answer key
- <h2 class="box">
- 35
- the gap round content
- 600px or narrower
- padding
- 20px
- .box
- justify-content
- green
- 50
- 136
- font-weight
- white
- width
- red
- #top
- 2
- HTML
- margin
- equal gaps, none at ends
- <p class="menu">
- display: flex
- True
- white
- False
- #end
- in the middle
- makes a form box
- <div class="star">
- 12
- h1
- 4
- the screen width
- <h1 id="hero">
- 80
- flex-end
- 4
- 24
- No
- 70
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids