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 1366px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 14px;
}
} (a) No (b) Yes - 2.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) 600px or narrower (c) exactly 1000px (d) 600px or wider
- 3.🎯 Which sign starts an id selector? (a) # (b) & (c) @ (d) .
- 4.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) neither (c) the shorter one (d) the first one
- 5.✍️ Which sign goes between a property and its value? (a) - (b) = (c) ; (d) :
- 6.💪 Which flexbox property turns on flexbox? (a) gap (b) justify-content (c) align-items (d) display: flex
-
7.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 14px;
}
} -
8.🖌️ What colour is behind the letters?
h1 {
text-align: right;
font-size: 20px;
color: purple;
background-color: yellow;
} (a) black (b) yellow (c) purple - 9.Which of these is margin? (a) a solid or dotted edge (b) the gap to other boxes (c) the line round the box (d) space inside the border
-
10.⚖️ What colour is the text of this element?
<h1 class="star" id="hero">Hi</h1>
CSS:
.star { color: white; }
.star { color: green; } (a) white (b) red (c) green (d) black -
11.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 110px;
padding: 5px;
border: 3px solid black;
margin: 15px;
} - 12.✍️ In color: blue; which part is the value? (a) : (b) ; (c) color (d) blue
- 13.🧩 Which language makes a link? (a) CSS (b) JavaScript (c) HTML
- 14.🎯 What kind of selector is .big? (a) a class selector (b) an id selector (c) an element selector
- 15.🌈 Which hex code is red? (a) #ff0000 (b) #0000ff (c) #000000 (d) #ffff00
- 16.Which of these is padding? (a) the text or picture (b) the line round the box (c) the gap round content (d) space outside the border
-
17.⚖️ What colour is the text of this element?
<p class="red" id="end">Hi</p>
CSS:
p { color: purple; }
p { color: white; } (a) purple (b) white (c) black (d) orange -
18.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 10px;
}
} - 19.Which of these is the content? (a) the text or picture (b) the gap round content (c) the gap to other boxes (d) space outside the border
-
20.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 20px;
}
} - 21.🎯 Which sign starts a class selector? (a) # (b) & (c) @ (d) .
- 22.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
- 23.🌈 Which hex code is yellow? (a) #00ffff (b) #ff0000 (c) #ffff00 (d) #00ff00
-
24.⚖️ What colour is the text of this element?
<h2 class="note" id="hero">Hi</h2>
CSS:
h2 { color: orange; }
#hero { color: yellow; } (a) red (b) yellow (c) orange (d) blue - 25.💪 Which justify-content value packs boxes at the start? (a) space-between (b) flex-start (c) center (d) flex-end
- 26.🔍 Which is the odd one out? (a) lays out the page (b) changes the text size (c) adds space around boxes (d) gives the page structure
-
27.✍️ Which property is set to yellow in this rule?
h1 {
background-color: yellow;
font-style: italic;
} (a) background-color (b) padding (c) yellow (d) margin -
28.✍️ What value is given to margin in this rule?
h1 {
background-color: yellow;
margin: 10px;
padding: 8px;
} (a) 8px (b) bold (c) 10px (d) margin - 29.📦 In the box model, which part is the gap round content? (a) border (b) margin (c) content (d) padding
- 30.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
- 31.True or false: CSS shows a pop-up message. (a) False (b) True
- 32.🎯 What kind of selector is .star? (a) an id selector (b) a class selector (c) an element selector
- 33.🧩 Which language makes headings and lists? (a) CSS (b) HTML (c) JavaScript
-
34.✍️ Which property is set to 2px solid in this rule?
p {
border: 2px solid;
margin: 10px;
} (a) 2px solid (b) border (c) width (d) font-style -
35.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 14px;
}
} - 36.🎯 How many elements on a page should have the same id? (a) 2 (b) 1 (c) any number (d) 5
-
37.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 20px;
}
} (a) Yes (b) No -
38.⚖️ What colour is the text of this element?
<p class="note" id="end">Hi</p>
CSS:
p { color: black; }
p { color: red; } (a) blue (b) black (c) red (d) orange - 39.What does justify-content: flex-end do? (a) puts boxes in the middle (b) packs boxes at the end (c) equal gaps, none at ends (d) packs boxes at the start
-
40.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 210px;
padding: 5px;
border: 2px solid black;
margin: 10px;
}
Answer key
- No
- 600px or narrower
- #
- the later one
- :
- display: flex
- 12
- yellow
- the gap to other boxes
- green
- 156
- blue
- HTML
- a class selector
- #ff0000
- the gap round content
- white
- 12
- the text or picture
- 16
- .
- an id selector
- #ffff00
- yellow
- flex-start
- gives the page structure
- background-color
- 10px
- padding
- equal gaps, none at ends
- False
- a class selector
- HTML
- border
- 14
- 1
- No
- red
- packs boxes at the end
- 244
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids