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 top to bottom (px) does this box take in all, margin included?
.box {
height: 150px;
padding: 10px;
border: 3px solid black;
margin: 0px;
} - 2.🌈 Which hex code is bright green? (a) #ffffff (b) #00ff00 (c) #0000ff (d) #00ffff
- 3.🧩 Which language shows a pop-up message? (a) HTML (b) JavaScript (c) CSS
- 4.What does justify-content: flex-start do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the start (d) packs boxes at the end
-
5.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 90px;
padding: 20px;
border: 5px solid black;
margin: 15px;
} -
6.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 12px;
}
} (a) No (b) Yes - 7.📱 min-width: 800px applies when the screen is ___. (a) exactly 100px (b) turned off (c) 800px or wider (d) 800px or narrower
-
8.🎯 Which CSS selector matches this element?
<p class="big" id="top">Hello</p> (a) #big (b) #top (c) h1 (d) .top -
9.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 120px;
justify-content: center;
}
Inside are 2 boxes, each 40px wide (no margins). -
10.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 30px;
}
} (a) No (b) Yes -
11.🎯 Which CSS selector matches this element?
<span class="menu" id="intro">Hello</span> (a) #menu (b) .intro (c) p (d) #intro - 12.Which of these does HTML do? (a) counts down a timer (b) gives the page structure (c) adds space around boxes (d) sets colours and fonts
- 13.🧩 Which language rounds box corners? (a) JavaScript (b) HTML (c) CSS
- 14.What does font-family do? (a) makes the text bold (b) makes letters bigger (c) picks the font style (d) colours behind the text
-
15.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 4 boxes, each 60px wide (no margins). -
16.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 480px) {
p {
font-size: 12px;
}
} -
17.⚖️ What colour is the text of this element?
<p class="star" id="hero">Hi</p>
CSS:
.star { color: white; }
p { color: green; }
#hero { color: purple; } (a) purple (b) white (c) black (d) green - 18.🖌️ Which CSS property sets the letter colour? (a) color (b) font-family (c) background-color (d) font-size
- 19.💪 Which flexbox property spaces boxes along a row? (a) flex-direction (b) align-items (c) gap (d) justify-content
-
20.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 150px;
justify-content: flex-start;
}
Inside are 2 boxes, each 50px wide (no margins). -
21.🎯 Which CSS selector matches this element?
<li class="star" id="hero">Hello</li> (a) .hero (b) #hero (c) #star (d) div - 22.🎨 What does CSS stand for? (a) Colourful Site Styles (b) Creative Sheet System (c) Cascading Style Sheets (d) Computer Style Sheets
-
23.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 190px;
padding: 10px;
border: 4px solid black;
margin: 20px;
} -
24.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 8px;
}
} - 25.🎯 Which sign starts a class selector? (a) @ (b) # (c) & (d) .
- 26.🌈 Which colour is rgb(0, 255, 0)? (a) bright green (b) black (c) white (d) red
- 27.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 2 (b) 4 (c) 3 (d) 6
- 28.🎯 Which element does the selector h1 style? (a) <div id="end"> (b) <h2> (c) <h1 class="note"> (d) <li class="note">
- 29.True or false: the content is the gap to other boxes. (a) True (b) False
- 30.🖌️ Which CSS property colours behind the text? (a) font-family (b) background-color (c) font-size (d) font-weight
-
31.🖌️ What colour is behind the letters?
li {
text-align: center;
background-color: yellow;
font-size: 40px;
color: green;
} (a) black (b) green (c) yellow - 32.True or false: CSS rounds box corners. (a) True (b) False
- 33.✍️ CSS declarations go inside which brackets? (a) [ ] (b) { } (c) < > (d) ( )
- 34.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
- 35.✍️ How does a CSS comment start? (a) /* (b) <!-- (c) # (d) //
- 36.🎯 Which element does the selector .star style? (a) <li id="star"> (b) <div class="note"> (c) <li class="star"> (d) <li class="menu">
- 37.🌈 Which hex code is blue? (a) #00ff00 (b) #0000ff (c) #ffffff (d) #ffff00
-
38.🎯 Which CSS selector matches this element?
<div class="red" id="intro">Hello</div> (a) .box (b) #intro (c) #red (d) #main -
39.🖌️ What colour are the letters?
p {
text-align: left;
font-size: 32px;
color: green;
background-color: black;
} (a) yellow (b) green (c) black -
40.⚖️ What colour is the text of this element?
<p class="menu" id="top">Hi</p>
CSS:
p { color: green; }
p { color: blue; } (a) red (b) purple (c) green (d) blue
Answer key
- 176
- #00ff00
- JavaScript
- packs boxes at the start
- 170
- No
- 800px or wider
- #top
- 20
- Yes
- #intro
- gives the page structure
- CSS
- picks the font style
- 10
- 16
- purple
- color
- justify-content
- 50
- #hero
- Cascading Style Sheets
- 258
- 8
- .
- bright green
- 3
- <h1 class="note">
- False
- background-color
- yellow
- True
- { }
- an id selector
- /*
- <li class="star">
- #0000ff
- #intro
- green
- blue
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids