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 element does the selector .big style? (a) <p class="red"> (b) <p class="big"> (c) <h1 class="box"> (d) <p id="big">
- 2.🌈 Which hex code is yellow? (a) #000000 (b) #ffffff (c) #ffff00 (d) #ff0000
- 3.🔍 Which is the odd one out? (a) changes the page live (b) changes the text size (c) reacts to a button click (d) counts down a timer
-
4.✍️ Which property is set to 300px in this rule?
h2 {
padding: 8px;
text-align: center;
margin: 10px;
width: 300px;
} (a) color (b) font-style (c) width (d) 300px - 5.📦 In the box model, which part is space outside the border? (a) margin (b) border (c) content (d) padding
- 6.🔍 Which is the odd one out? (a) makes headings and lists (b) makes a form box (c) makes a link (d) lays out the page
- 7.🌈 Which colour is #ff00ff? (a) red (b) white (c) bright green (d) magenta
- 8.🎯 Which element does the selector .box style? (a) <div class="menu"> (b) <li class="box"> (c) <li class="star"> (d) <li id="box">
- 9.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
- 10.🎯 Which element does the selector .box style? (a) <h2 class="menu"> (b) <h1 id="box"> (c) <h1 class="star"> (d) <h1 class="box">
- 11.🌈 Which colour is rgb(0, 255, 255)? (a) magenta (b) black (c) cyan (d) red
-
12.🖌️ How big is the text, in px?
h1 {
color: red;
text-align: right;
background-color: orange;
font-size: 20px;
} - 13.What does justify-content: space-between do? (a) packs boxes at the end (b) puts boxes in the middle (c) packs boxes at the start (d) equal gaps, none at ends
- 14.What does font-size do? (a) sets the letter colour (b) makes letters bigger (c) picks the font style (d) centres a heading
-
15.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 20px;
}
} - 16.🌈 Which colour is #0000ff? (a) white (b) blue (c) cyan (d) bright green
- 17.True or false: padding is space inside the border. (a) True (b) False
- 18.✍️ In color: blue; which part is the property? (a) color (b) : (c) ; (d) blue
- 19.💪 Which justify-content value packs boxes at the end? (a) center (b) space-between (c) flex-start (d) flex-end
- 20.🌈 Which colour is rgb(0, 255, 0)? (a) black (b) blue (c) white (d) bright green
- 21.✍️ Which sign ends each CSS declaration? (a) , (b) . (c) : (d) ;
- 22.📦 In the box model, which part is the line round the box? (a) border (b) content (c) margin (d) padding
- 23.🌈 In #e10000 the red part is the hex number e1. What is it as a normal number?
- 24.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
- 25.🌈 In #009c00 the green part is the hex number 9c. What is it as a normal number?
- 26.🌈 Which colour of light is strongest in rgb(27, 160, 32)? (a) blue (b) green (c) red
-
27.🎯 Which CSS selector matches this element?
<div class="red" id="intro">Hello</div> (a) .red (b) span (c) #red (d) .intro - 28.True or false: padding is the gap round content. (a) True (b) False
- 29.🌈 Which hex code is blue? (a) #ffffff (b) #ff00ff (c) #0000ff (d) #00ffff
-
30.⚖️ What colour is the text of this element?
<h2 class="menu" id="end">Hi</h2>
CSS:
#end { color: red; }
h2 { color: purple; } (a) black (b) red (c) white (d) purple - 31.🎨 Which tag holds CSS inside the head? (a) <script> (b) <css> (c) <style> (d) <body>
-
32.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 16px;
}
} - 33.📱 What does a media query check? (a) the screen width (b) the time of day (c) the page title (d) the battery level
-
34.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 1024px) {
p {
font-size: 20px;
}
} (a) Yes (b) No - 35.What does justify-content: flex-end do? (a) packs boxes at the start (b) equal gaps, none at ends (c) puts boxes in the middle (d) packs boxes at the end
- 36.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) 600px or wider (c) exactly 1000px (d) 600px or narrower
-
37.✍️ Which property is set to 20px in this rule?
body {
background-color: yellow;
font-size: 20px;
} (a) background-color (b) 20px (c) text-align (d) font-size -
38.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 180px;
justify-content: center;
}
Inside are 2 boxes, each 60px wide (no margins). - 39.🎯 How many elements on a page should have the same id? (a) 2 (b) any number (c) 5 (d) 1
- 40.📱 min-width: 800px applies when the screen is ___. (a) exactly 100px (b) 800px or narrower (c) turned off (d) 800px or wider
Answer key
- <p class="big">
- #ffff00
- changes the text size
- width
- margin
- lays out the page
- magenta
- <li class="box">
- an element selector
- <h1 class="box">
- cyan
- 20
- equal gaps, none at ends
- makes letters bigger
- 16
- blue
- True
- color
- flex-end
- bright green
- ;
- border
- 225
- an id selector
- 156
- green
- .red
- True
- #0000ff
- red
- <style>
- 16
- the screen width
- Yes
- packs boxes at the end
- 600px or narrower
- font-size
- 30
- 1
- 800px or wider
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids