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 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 18px;
}
} -
2.🖌️ What colour is behind the letters?
li {
font-size: 32px;
color: white;
background-color: black;
text-align: right;
} (a) white (b) black (c) purple - 3.What does justify-content: space-between do? (a) packs boxes at the end (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the start
- 4.🧩 Which language adds space around boxes? (a) JavaScript (b) HTML (c) CSS
- 5.🔍 Which is the odd one out? (a) checks a quiz answer (b) shows a pop-up message (c) puts a picture on a page (d) changes the page live
- 6.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
-
7.⚖️ What colour is the text of this element?
<h2 class="big" id="top">Hi</h2>
CSS:
#top { color: yellow; }
h2 { color: white; }
.big { color: orange; } (a) orange (b) blue (c) yellow (d) white -
8.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 150px;
padding: 5px;
border: 1px solid black;
margin: 0px;
} - 9.📱 What does a media query check? (a) the screen width (b) the battery level (c) the page title (d) the time of day
-
10.🎯 Which CSS selector matches this element?
<p class="menu" id="end">Hello</p> (a) #menu (b) .note (c) #end (d) #hero -
11.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 180px;
justify-content: flex-end;
}
Inside are 4 boxes, each 40px wide (no margins). -
12.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} -
13.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 200px;
justify-content: flex-end;
}
Inside are 4 boxes, each 40px wide (no margins). -
14.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 1024px) {
p {
font-size: 30px;
}
} (a) Yes (b) No -
15.⚖️ What colour is the text of this element?
<h2 class="menu" id="intro">Hi</h2>
CSS:
.menu { color: red; }
.menu { color: yellow; } (a) red (b) black (c) green (d) yellow - 16.✍️ How does a CSS comment start? (a) <!-- (b) /* (c) # (d) //
-
17.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 600px) {
p {
font-size: 24px;
}
} - 18.🎯 What kind of selector is #main? (a) an id selector (b) a class selector (c) an element selector
- 19.✍️ Which sign ends each CSS declaration? (a) : (b) , (c) . (d) ;
-
20.⚖️ What colour is the text of this element?
<p class="star" id="logo">Hi</p>
CSS:
#logo { color: green; }
p { color: purple; } (a) white (b) black (c) purple (d) green - 21.🔍 Which is the odd one out? (a) counts down a timer (b) lays out the page (c) adds space around boxes (d) rounds box corners
-
22.✍️ What value is given to padding in this rule?
li {
color: red;
padding: 8px;
text-align: center;
font-weight: bold;
} (a) bold (b) padding (c) 2px solid (d) 8px -
23.🎯 Which CSS selector matches this element?
<p class="red" id="intro">Hello</p> (a) #red (b) h1 (c) .intro (d) .red -
24.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 70px;
padding: 20px;
border: 5px solid black;
margin: 10px;
} - 25.True or false: HTML makes a form box. (a) False (b) True
- 26.🌈 Which hex code is bright green? (a) #ffff00 (b) #ff00ff (c) #00ffff (d) #00ff00
- 27.💪 Which flexbox property lines boxes up across? (a) display: flex (b) flex-direction (c) align-items (d) justify-content
- 28.🧩 Which language shows a pop-up message? (a) HTML (b) JavaScript (c) CSS
-
29.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 8px;
}
} (a) No (b) Yes - 30.🎯 What kind of selector is #hero? (a) an id selector (b) a class selector (c) an element selector
- 31.🎨 Which attribute adds CSS inside one tag? (a) src (b) href (c) style (d) alt
- 32.🌈 Which hex code is yellow? (a) #ff00ff (b) #ffff00 (c) #0000ff (d) #00ffff
-
33.🖌️ What colour are the letters?
h1 {
text-align: left;
font-size: 24px;
background-color: red;
color: orange;
} (a) red (b) orange (c) white -
34.✍️ Which property is set to 300px in this rule?
.box {
text-align: center;
color: red;
width: 300px;
font-weight: bold;
} (a) color (b) font-style (c) 300px (d) width - 35.True or false: padding is space outside the border. (a) True (b) False
-
36.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 170px;
justify-content: flex-start;
}
Inside are 3 boxes, each 40px wide (no margins). - 37.🧩 Which language makes headings and lists? (a) HTML (b) JavaScript (c) CSS
- 38.🎯 Which sign starts a class selector? (a) & (b) @ (c) . (d) #
- 39.🌈 Which colour is #ffffff? (a) black (b) bright green (c) cyan (d) white
-
40.✍️ What value is given to color in this rule?
p {
color: red;
font-style: italic;
font-weight: bold;
} (a) color (b) center (c) 20px (d) red
Answer key
- 18
- black
- equal gaps, none at ends
- CSS
- puts a picture on a page
- an id selector
- yellow
- 162
- the screen width
- #end
- 20
- 24
- 40
- No
- yellow
- /*
- 24
- an id selector
- ;
- green
- counts down a timer
- 8px
- .red
- 140
- True
- #00ff00
- align-items
- JavaScript
- Yes
- an id selector
- style
- #ffff00
- orange
- width
- False
- 50
- HTML
- .
- white
- red
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids