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 CSS selector matches this element?
<p class="box" id="main">Hello</p> (a) p (b) #box (c) .star (d) .main - 2.📱 min-width: 800px applies when the screen is ___. (a) 800px or wider (b) 800px or narrower (c) turned off (d) exactly 100px
-
3.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 18px;
}
} - 4.🎯 Which element does the selector #end style? (a) <span id="hero"> (b) <span id="end"> (c) <p class="big"> (d) <span class="end">
-
5.⚖️ What colour is the text of this element?
<p class="menu" id="main">Hi</p>
CSS:
.menu { color: black; }
#main { color: red; } (a) purple (b) green (c) black (d) red -
6.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 350px;
justify-content: flex-end;
}
Inside are 4 boxes, each 80px wide (no margins). -
7.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 360px;
justify-content: center;
}
Inside are 3 boxes, each 80px wide (no margins). - 8.🔍 Which is the odd one out? (a) puts a picture on a page (b) makes a link (c) changes the page live (d) gives the page structure
- 9.🌈 In #0000f8 the blue part is the hex number f8. What is it as a normal number?
-
10.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 400px;
justify-content: center;
}
Inside are 3 boxes, each 80px wide (no margins). -
11.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 140px;
padding: 30px;
border: 1px solid black;
margin: 10px;
} - 12.📦 In the box model, which part is the text or picture? (a) padding (b) margin (c) border (d) content
-
13.⚖️ What colour is the text of this element?
<h2 class="box" id="top">Hi</h2>
CSS:
h2 { color: green; }
h2 { color: red; } (a) red (b) green (c) orange (d) black - 14.True or false: the content is the line round the box. (a) True (b) False
-
15.✍️ What is the selector in this CSS rule?
h1 {
width: 300px;
border: 2px solid;
font-weight: bold;
font-style: italic;
} (a) width (b) 2px solid (c) p (d) h1 -
16.⚖️ What colour is the text of this element?
<h2 class="note" id="top">Hi</h2>
CSS:
.note { color: red; }
h2 { color: green; } (a) orange (b) green (c) red (d) yellow -
17.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 390px;
justify-content: flex-start;
}
Inside are 4 boxes, each 80px wide (no margins). - 18.🎯 Which element does the selector div style? (a) <span> (b) <div class="red"> (c) <p class="red"> (d) <h1 id="intro">
-
19.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} - 20.🔍 Which is the odd one out? (a) makes a form box (b) counts down a timer (c) changes the page live (d) reacts to a button click
-
21.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 240px;
justify-content: flex-start;
}
Inside are 4 boxes, each 50px wide (no margins). -
22.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 16px;
}
} (a) No (b) Yes -
23.✍️ What is the selector in this CSS rule?
#top {
font-style: italic;
color: red;
background-color: yellow;
} (a) li (b) #top (c) red (d) font-style -
24.🖌️ Where does the text sit on its line?
h1 {
text-align: left;
background-color: orange;
font-size: 40px;
color: blue;
} (a) on the right (b) on the left (c) in the middle - 25.🌈 Which colour is #00ff00? (a) bright green (b) white (c) red (d) yellow
-
26.🖌️ What colour is behind the letters?
li {
font-size: 24px;
background-color: white;
color: black;
text-align: right;
} (a) purple (b) black (c) white - 27.🎯 How many elements on a page should have the same id? (a) 2 (b) any number (c) 5 (d) 1
- 28.🔍 Which is the odd one out? (a) makes a link (b) makes headings and lists (c) gives the page structure (d) shows a pop-up message
- 29.📦 In the box model, which part is the line round the box? (a) border (b) padding (c) content (d) margin
- 30.💪 Which flexbox property lines boxes up across? (a) flex-direction (b) gap (c) display: flex (d) align-items
-
31.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 190px;
justify-content: flex-start;
}
Inside are 3 boxes, each 50px wide (no margins). - 32.True or false: #hero is an id selector. (a) False (b) True
- 33.What does font-size do? (a) sets the letter colour (b) makes letters bigger (c) colours behind the text (d) picks the font style
- 34.🎯 Can many elements share the same class? (a) No (b) Yes
-
35.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 600px) {
p {
font-size: 22px;
}
} - 36.True or false: JavaScript gives the page structure. (a) False (b) True
- 37.📱 Which tag helps phones show a page at the right size? (a) the br tag (b) the title tag (c) the hr tag (d) the viewport meta tag
- 38.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) white (c) blue (d) green
-
39.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 200px;
justify-content: flex-start;
}
Inside are 2 boxes, each 60px wide (no margins). -
40.🎯 Which CSS selector matches this element?
<li class="note" id="end">Hello</li> (a) .big (b) .note (c) #hero (d) div
Answer key
- p
- 800px or wider
- 18
- <span id="end">
- red
- 30
- 60
- changes the page live
- 248
- 80
- 222
- content
- red
- False
- h1
- red
- 70
- <div class="red">
- 10
- makes a form box
- 40
- No
- #top
- on the left
- bright green
- white
- 1
- shows a pop-up message
- border
- align-items
- 40
- True
- makes letters bigger
- Yes
- 20
- False
- the viewport meta tag
- blue
- 80
- .note
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids