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?
<h1 class="big" id="intro">Hello</h1> (a) .intro (b) #main (c) h1 (d) .red -
2.🖌️ What colour is behind the letters?
h1 {
color: red;
text-align: left;
background-color: purple;
font-size: 28px;
} (a) purple (b) yellow (c) red - 3.🎯 Which element does the selector p style? (a) <h1> (b) <h2 class="red"> (c) <p class="red"> (d) <li id="end">
- 4.📱 Responsive design means a page ___. (a) never changes (b) is only for laptops (c) has no pictures (d) fits every screen
-
5.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 2 boxes, each 60px wide (no margins). - 6.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) white (c) red (d) blue
- 7.🎯 Which element does the selector #logo style? (a) <h2 id="end"> (b) <h2 id="logo"> (c) <li class="big"> (d) <h2 class="logo">
-
8.⚖️ What colour is the text of this element?
<h2 class="big" id="main">Hi</h2>
CSS:
#main { color: red; }
h2 { color: green; }
.big { color: white; } (a) green (b) white (c) red (d) black - 9.🖌️ Which CSS property picks the font style? (a) color (b) font-size (c) background-color (d) font-family
- 10.✍️ In color: blue; which part is the property? (a) ; (b) blue (c) color (d) :
-
11.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 600px) {
p {
font-size: 24px;
}
} -
12.🖌️ How big is the text, in px?
h2 {
color: red;
background-color: black;
font-size: 28px;
text-align: right;
} - 13.🎯 What kind of selector is #main? (a) a class selector (b) an element selector (c) an id selector
- 14.💪 Which justify-content value packs boxes at the start? (a) flex-start (b) center (c) flex-end (d) space-between
- 15.What does color do? (a) picks the font style (b) colours behind the text (c) makes letters bigger (d) sets the letter colour
-
16.✍️ What is the selector in this CSS rule?
#top {
margin: 10px;
color: red;
text-align: center;
} (a) margin (b) red (c) li (d) #top -
17.✍️ What is the selector in this CSS rule?
.note {
font-style: italic;
border: 2px solid;
font-weight: bold;
font-size: 20px;
} (a) #top (b) font-style (c) 2px solid (d) .note - 18.What does justify-content: center do? (a) equal gaps, none at ends (b) packs boxes at the start (c) puts boxes in the middle (d) packs boxes at the end
- 19.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
-
20.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 18px;
}
} - 21.🌈 Which colour is #ff0000? (a) cyan (b) bright green (c) blue (d) red
- 22.📱 max-width: 600px applies when the screen is ___. (a) 600px or narrower (b) exactly 1000px (c) 600px or wider (d) turned off
- 23.True or false: HTML rounds box corners. (a) True (b) False
- 24.✍️ Which sign goes between a property and its value? (a) = (b) ; (c) - (d) :
-
25.⚖️ What colour is the text of this element?
<p class="box" id="top">Hi</p>
CSS:
#top { color: green; }
#top { color: yellow; } (a) black (b) green (c) orange (d) yellow -
26.⚖️ What colour is the text of this element?
<h1 class="red" id="end">Hi</h1>
CSS:
h1 { color: purple; }
h1 { color: yellow; } (a) black (b) blue (c) purple (d) yellow - 27.True or false: HTML puts a picture on a page. (a) False (b) True
-
28.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 200px;
padding: 20px;
border: 5px solid black;
margin: 15px;
} - 29.✍️ How does a CSS comment start? (a) <!-- (b) // (c) /* (d) #
- 30.Which of these does JavaScript do? (a) reacts to a button click (b) makes a link (c) lays out the page (d) gives the page structure
- 31.🌈 Which colour is rgb(255, 255, 255)? (a) blue (b) white (c) red (d) bright green
- 32.True or false: #logo is a class selector. (a) False (b) True
-
33.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 170px;
justify-content: flex-end;
}
Inside are 3 boxes, each 50px wide (no margins). - 34.📦 In the box model, which part is a solid or dotted edge? (a) border (b) margin (c) padding (d) content
- 35.🌈 Which colour is rgb(255, 0, 255)? (a) black (b) white (c) cyan (d) magenta
- 36.💪 Which flexbox property spaces boxes along a row? (a) justify-content (b) display: flex (c) gap (d) align-items
- 37.🧩 Which language adds space around boxes? (a) JavaScript (b) HTML (c) CSS
- 38.What does justify-content: flex-start do? (a) equal gaps, none at ends (b) packs boxes at the start (c) packs boxes at the end (d) puts boxes in the middle
- 39.🎯 Which sign starts an id selector? (a) & (b) . (c) # (d) @
-
40.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 190px;
padding: 10px;
border: 1px solid black;
margin: 0px;
}
Answer key
- h1
- purple
- <p class="red">
- fits every screen
- 70
- blue
- <h2 id="logo">
- red
- font-family
- color
- 20
- 28
- an id selector
- flex-start
- sets the letter colour
- #top
- .note
- puts boxes in the middle
- an element selector
- 16
- red
- 600px or narrower
- False
- :
- yellow
- yellow
- True
- 280
- /*
- reacts to a button click
- white
- False
- 20
- border
- magenta
- justify-content
- CSS
- packs boxes at the start
- #
- 212
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids