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.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 230px;
padding: 25px;
border: 2px solid black;
margin: 15px;
} - 2.What does justify-content: space-between do? (a) packs boxes at the start (b) packs boxes at the end (c) equal gaps, none at ends (d) puts boxes in the middle
-
3.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 4 boxes, each 40px wide (no margins). -
4.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 100px;
padding: 30px;
border: 3px solid black;
margin: 20px;
} - 5.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) red (c) white (d) green
- 6.🎯 What kind of selector is .big? (a) an element selector (b) a class selector (c) an id selector
-
7.✍️ What value is given to margin in this rule?
h2 {
margin: 10px;
font-size: 20px;
} (a) 8px (b) 10px (c) bold (d) margin - 8.💪 Which justify-content value puts boxes in the middle? (a) flex-end (b) center (c) space-between (d) flex-start
- 9.🔍 Which is the odd one out? (a) rounds box corners (b) puts a picture on a page (c) adds space around boxes (d) sets colours and fonts
- 10.True or false: CSS adds space around boxes. (a) True (b) False
-
11.🎯 Which CSS selector matches this element?
<li class="star" id="main">Hello</li> (a) .menu (b) .main (c) div (d) li - 12.📱 Responsive design means a page ___. (a) is only for laptops (b) has no pictures (c) fits every screen (d) never changes
- 13.💪 Which justify-content value packs boxes at the start? (a) space-between (b) flex-end (c) center (d) flex-start
-
14.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 1024px) {
p {
font-size: 18px;
}
} (a) No (b) Yes - 15.Which of these does JavaScript do? (a) rounds box corners (b) puts a picture on a page (c) makes a form box (d) counts down a timer
- 16.Which of these does CSS do? (a) counts down a timer (b) puts a picture on a page (c) makes a form box (d) lays out the page
- 17.Which of these is padding? (a) a solid or dotted edge (b) the line round the box (c) the gap to other boxes (d) the gap round content
-
18.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 460px;
justify-content: space-between;
}
Inside are 4 boxes, each 100px wide (no margins). -
19.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 20px;
}
} - 20.True or false: padding is space inside the border. (a) False (b) True
- 21.🧩 Which language makes a form box? (a) CSS (b) HTML (c) JavaScript
- 22.🌈 Which hex code is red? (a) #0000ff (b) #ff0000 (c) #000000 (d) #00ff00
- 23.Which of these does HTML do? (a) counts down a timer (b) adds space around boxes (c) checks a quiz answer (d) makes headings and lists
- 24.🎯 Which element does the selector #top style? (a) <span id="top"> (b) <span class="top"> (c) <span id="intro"> (d) <p class="red">
-
25.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 320px;
justify-content: flex-end;
}
Inside are 3 boxes, each 100px wide (no margins). -
26.⚖️ What colour is the text of this element?
<h1 class="note" id="hero">Hi</h1>
CSS:
h1 { color: white; }
.note { color: blue; } (a) white (b) yellow (c) red (d) blue - 27.🔍 Which is the odd one out? (a) gives the page structure (b) puts a picture on a page (c) makes a form box (d) changes the text size
-
28.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 22px;
}
} -
29.🖌️ How big is the text, in px?
p {
text-align: center;
background-color: blue;
font-size: 36px;
color: red;
} - 30.📦 In the box model, which part is space outside the border? (a) margin (b) border (c) content (d) padding
- 31.🎯 Which element does the selector #hero style? (a) <p class="hero"> (b) <h1 class="star"> (c) <p id="top"> (d) <p id="hero">
- 32.🎯 Can many elements share the same class? (a) No (b) Yes
- 33.🖌️ Which CSS property makes letters bigger? (a) text-align (b) font-weight (c) color (d) font-size
-
34.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 8px;
}
} (a) No (b) Yes -
35.⚖️ What colour is the text of this element?
<h1 class="note" id="end">Hi</h1>
CSS:
h1 { color: yellow; }
h1 { color: orange; } (a) white (b) black (c) orange (d) yellow - 36.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
-
37.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 90px;
justify-content: flex-end;
}
Inside are 2 boxes, each 40px wide (no margins). - 38.True or false: HTML sets colours and fonts. (a) True (b) False
- 39.🎯 What kind of selector is #end? (a) a class selector (b) an element selector (c) an id selector
-
40.✍️ Which property is set to 10px in this rule?
h1 {
margin: 10px;
background-color: yellow;
font-style: italic;
} (a) padding (b) 10px (c) margin (d) font-weight
Answer key
- 314
- equal gaps, none at ends
- 50
- 166
- blue
- a class selector
- 10px
- center
- puts a picture on a page
- True
- li
- fits every screen
- flex-start
- Yes
- counts down a timer
- lays out the page
- the gap round content
- 20
- 16
- True
- HTML
- #ff0000
- makes headings and lists
- <span id="top">
- 20
- blue
- changes the text size
- 24
- 36
- margin
- <p id="hero">
- Yes
- font-size
- No
- orange
- an id selector
- 10
- False
- an id selector
- margin
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids