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 tag holds CSS inside the head? (a) <body> (b) <style> (c) <script> (d) <css>
-
2.⚖️ What colour is the text of this element?
<h1 class="menu" id="intro">Hi</h1>
CSS:
#intro { color: red; }
#intro { color: white; } (a) black (b) white (c) red (d) green -
3.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 170px;
justify-content: space-between;
}
Inside are 2 boxes, each 60px wide (no margins). - 4.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the shorter one (c) the first one (d) neither
-
5.⚖️ What colour is the text of this element?
<h1 class="note" id="top">Hi</h1>
CSS:
h1 { color: yellow; }
h1 { color: blue; } (a) blue (b) white (c) yellow (d) black -
6.✍️ Which property is set to 2px solid in this rule?
p {
border: 2px solid;
width: 300px;
padding: 8px;
margin: 10px;
} (a) font-style (b) border (c) 2px solid (d) width - 7.What does font-size do? (a) colours behind the text (b) picks the font style (c) makes letters bigger (d) sets the letter colour
- 8.🎯 Which element does the selector #end style? (a) <div class="end"> (b) <div id="hero"> (c) <span class="note"> (d) <div id="end">
-
9.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 28px;
}
} - 10.✍️ In color: blue; which part is the value? (a) color (b) ; (c) : (d) blue
-
11.✍️ What value is given to font-size in this rule?
.note {
font-weight: bold;
font-size: 20px;
} (a) 20px (b) font-size (c) yellow (d) center - 12.🧩 Which language changes the text size? (a) CSS (b) HTML (c) JavaScript
- 13.🎯 Can many elements share the same class? (a) Yes (b) No
-
14.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 240px;
padding: 15px;
border: 2px solid black;
margin: 15px;
} - 15.🎯 How many elements on a page should have the same id? (a) 5 (b) 1 (c) 2 (d) any number
-
16.⚖️ What colour is the text of this element?
<p class="star" id="hero">Hi</p>
CSS:
#hero { color: purple; }
p { color: blue; } (a) purple (b) orange (c) blue (d) yellow -
17.⚖️ What colour is the text of this element?
<p class="star" id="logo">Hi</p>
CSS:
#logo { color: orange; }
p { color: blue; }
.star { color: purple; } (a) green (b) purple (c) blue (d) orange -
18.⚖️ What colour is the text of this element?
<h2 class="box" id="end">Hi</h2>
CSS:
.box { color: green; }
.box { color: white; } (a) green (b) blue (c) white (d) black - 19.💪 Which flexbox property sets space between boxes? (a) justify-content (b) display: flex (c) flex-direction (d) gap
- 20.🎨 A CSS file usually ends with which extension? (a) .css (b) .html (c) .png (d) .js
- 21.📦 In the box model, which part is the line round the box? (a) border (b) margin (c) padding (d) content
- 22.🎨 Which attribute adds CSS inside one tag? (a) href (b) alt (c) src (d) style
- 23.✍️ Which sign ends each CSS declaration? (a) : (b) . (c) , (d) ;
- 24.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) exactly 100px (c) 800px or narrower (d) 800px or wider
-
25.🖌️ How big is the text, in px?
h1 {
font-size: 12px;
text-align: left;
background-color: green;
color: blue;
} - 26.🌈 In #470000 the red part is the hex number 47. What is it as a normal number?
- 27.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) justify-content (c) gap (d) display: flex
-
28.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 10px;
}
} - 29.🌈 Which colour is rgb(0, 0, 0)? (a) red (b) black (c) white (d) yellow
-
30.🎯 Which CSS selector matches this element?
<h1 class="big" id="top">Hello</h1> (a) #big (b) .red (c) h2 (d) .big - 31.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) red (c) blue (d) white
-
32.🖌️ What colour is behind the letters?
h1 {
color: red;
font-size: 20px;
background-color: green;
text-align: left;
} (a) green (b) purple (c) red -
33.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 600px) {
p {
font-size: 28px;
}
} (a) Yes (b) No -
34.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 16px;
}
} (a) Yes (b) No -
35.✍️ Which property is set to italic in this rule?
body {
font-weight: bold;
font-style: italic;
} (a) font-size (b) italic (c) font-style (d) color -
36.🖌️ What colour is behind the letters?
li {
background-color: orange;
text-align: left;
font-size: 12px;
color: purple;
} (a) white (b) purple (c) orange - 37.💪 Which justify-content value equal gaps, none at ends? (a) center (b) space-between (c) flex-start (d) flex-end
-
38.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 560px;
justify-content: center;
}
Inside are 4 boxes, each 100px wide (no margins). - 39.📱 What does a media query check? (a) the page title (b) the battery level (c) the time of day (d) the screen width
- 40.🖌️ Which CSS property centres a heading? (a) font-family (b) font-size (c) text-align (d) font-weight
Answer key
- <style>
- white
- 50
- the later one
- blue
- border
- makes letters bigger
- <div id="end">
- 28
- blue
- 20px
- CSS
- Yes
- 304
- 1
- purple
- orange
- white
- gap
- .css
- border
- style
- ;
- 800px or wider
- 12
- 71
- display: flex
- 10
- black
- .big
- blue
- green
- No
- No
- font-style
- orange
- space-between
- 80
- the screen width
- text-align
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids