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 is the odd one out? (a) adds space around boxes (b) counts down a timer (c) shows a pop-up message (d) changes the page live
- 2.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the shorter one (c) neither (d) the first one
- 3.True or false: the content is a solid or dotted edge. (a) False (b) True
-
4.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 16px;
}
} (a) Yes (b) No - 5.📦 In the box model, which part is space inside the border? (a) padding (b) content (c) margin (d) border
-
6.🖌️ What colour are the letters?
h1 {
color: orange;
text-align: left;
font-size: 20px;
background-color: green;
} (a) blue (b) green (c) orange -
7.⚖️ What colour is the text of this element?
<p class="big" id="top">Hi</p>
CSS:
p { color: purple; }
#top { color: red; } (a) white (b) purple (c) red (d) green -
8.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 240px;
justify-content: center;
}
Inside are 2 boxes, each 40px wide (no margins). -
9.✍️ What value is given to text-align in this rule?
.note {
font-size: 20px;
text-align: center;
background-color: yellow;
} (a) text-align (b) yellow (c) 10px (d) center - 10.🎯 Which element does the selector .note style? (a) <h2 class="red"> (b) <h1 class="note"> (c) <h1 class="big"> (d) <h1 id="note">
- 11.True or false: HTML checks a quiz answer. (a) True (b) False
- 12.📱 max-width: 600px applies when the screen is ___. (a) 600px or narrower (b) 600px or wider (c) exactly 1000px (d) turned off
-
13.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 180px;
justify-content: center;
}
Inside are 2 boxes, each 40px wide (no margins). -
14.🎯 Which CSS selector matches this element?
<div class="menu" id="hero">Hello</div> (a) div (b) span (c) .hero (d) #top - 15.📦 In the box model, which part is a solid or dotted edge? (a) content (b) margin (c) padding (d) border
- 16.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
-
17.✍️ Which property is set to yellow in this rule?
h1 {
font-weight: bold;
background-color: yellow;
color: red;
width: 300px;
} (a) margin (b) background-color (c) yellow (d) padding - 18.What does justify-content: flex-start do? (a) puts boxes in the middle (b) packs boxes at the end (c) packs boxes at the start (d) equal gaps, none at ends
-
19.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 240px;
justify-content: center;
}
Inside are 2 boxes, each 100px wide (no margins). - 20.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) blue (c) black (d) red
- 21.💪 Which flexbox property sets space between boxes? (a) justify-content (b) gap (c) display: flex (d) align-items
-
22.✍️ How many declarations (property: value pairs) are in this rule?
body {
font-weight: bold;
padding: 8px;
} -
23.🖌️ What colour are the letters?
h2 {
text-align: left;
font-size: 28px;
background-color: red;
color: white;
} (a) orange (b) red (c) white - 24.Which of these is the border? (a) space inside the border (b) the gap round content (c) space outside the border (d) a solid or dotted edge
- 25.Which of these does HTML do? (a) counts down a timer (b) sets colours and fonts (c) shows a pop-up message (d) makes headings and lists
-
26.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 110px;
padding: 10px;
border: 2px solid black;
margin: 5px;
} -
27.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 190px;
padding: 5px;
border: 2px solid black;
margin: 0px;
} -
28.⚖️ What colour is the text of this element?
<p class="box" id="top">Hi</p>
CSS:
p { color: red; }
.box { color: white; }
#top { color: green; } (a) red (b) green (c) purple (d) white - 29.True or false: padding is space inside the border. (a) True (b) False
- 30.Which of these does JavaScript do? (a) counts down a timer (b) rounds box corners (c) puts a picture on a page (d) makes a form box
- 31.True or false: JavaScript changes the text size. (a) False (b) True
-
32.🖌️ What colour is behind the letters?
h2 {
text-align: left;
color: red;
font-size: 32px;
background-color: green;
} (a) orange (b) red (c) green - 33.True or false: .star is an element selector. (a) True (b) False
- 34.🖌️ Which CSS property colours behind the text? (a) color (b) background-color (c) font-family (d) font-size
- 35.🔍 Which is the odd one out? (a) counts down a timer (b) changes the page live (c) lays out the page (d) shows a pop-up message
- 36.True or false: .card is a class selector. (a) False (b) True
-
37.⚖️ What colour is the text of this element?
<p class="star" id="logo">Hi</p>
CSS:
.star { color: black; }
#logo { color: white; } (a) white (b) black (c) orange (d) green - 38.💪 Which justify-content value packs boxes at the end? (a) flex-start (b) space-between (c) center (d) flex-end
- 39.🌈 Which colour is #ff0000? (a) blue (b) yellow (c) red (d) bright green
-
40.✍️ What value is given to background-color in this rule?
#top {
text-align: center;
background-color: yellow;
} (a) 8px (b) background-color (c) yellow (d) 10px
Answer key
- adds space around boxes
- the later one
- False
- Yes
- padding
- orange
- red
- 80
- center
- <h1 class="note">
- False
- 600px or narrower
- 50
- div
- border
- an id selector
- background-color
- packs boxes at the start
- 20
- red
- gap
- 2
- white
- a solid or dotted edge
- makes headings and lists
- 144
- 204
- green
- True
- counts down a timer
- False
- green
- False
- background-color
- lays out the page
- True
- white
- flex-end
- red
- yellow
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids