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.🎯 What kind of selector is .big? (a) an element selector (b) an id selector (c) a class selector
-
2.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 420px;
justify-content: space-between;
}
Inside are 3 boxes, each 100px wide (no margins). - 3.🌈 Which colour is #00ffff? (a) red (b) cyan (c) yellow (d) magenta
-
4.⚖️ What colour is the text of this element?
<p class="box" id="hero">Hi</p>
CSS:
#hero { color: yellow; }
#hero { color: purple; } (a) yellow (b) purple (c) blue (d) black -
5.🎯 Which CSS selector matches this element?
<h1 class="menu" id="end">Hello</h1> (a) #hero (b) .note (c) h2 (d) .menu - 6.🎯 What kind of selector is .star? (a) an id selector (b) an element selector (c) a class selector
- 7.🔍 Which is the odd one out? (a) reacts to a button click (b) makes a form box (c) changes the page live (d) checks a quiz answer
-
8.⚖️ What colour is the text of this element?
<p class="red" id="intro">Hi</p>
CSS:
p { color: red; }
p { color: purple; } (a) green (b) red (c) purple (d) black - 9.Which of these does HTML do? (a) changes the page live (b) reacts to a button click (c) adds space around boxes (d) gives the page structure
-
10.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 120px;
justify-content: flex-start;
}
Inside are 2 boxes, each 40px wide (no margins). - 11.📱 max-width: 600px applies when the screen is ___. (a) 600px or narrower (b) turned off (c) exactly 1000px (d) 600px or wider
- 12.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) white (c) blue (d) green
-
13.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 22px;
}
} (a) Yes (b) No -
14.⚖️ What colour is the text of this element?
<h2 class="menu" id="end">Hi</h2>
CSS:
h2 { color: red; }
h2 { color: orange; } (a) white (b) orange (c) purple (d) red -
15.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 260px;
padding: 25px;
border: 1px solid black;
margin: 15px;
} -
16.⚖️ What colour is the text of this element?
<p class="menu" id="logo">Hi</p>
CSS:
#logo { color: white; }
#logo { color: red; } (a) orange (b) white (c) black (d) red - 17.📦 In the box model, which part is the text or picture? (a) border (b) content (c) margin (d) padding
- 18.💪 Which flexbox property turns on flexbox? (a) display: flex (b) gap (c) align-items (d) justify-content
-
19.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} - 20.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
-
21.✍️ Which property is set to italic in this rule?
.note {
text-align: center;
padding: 8px;
font-size: 20px;
font-style: italic;
} (a) italic (b) font-style (c) color (d) font-size - 22.Which of these does CSS do? (a) puts a picture on a page (b) counts down a timer (c) adds space around boxes (d) reacts to a button click
-
23.⚖️ What colour is the text of this element?
<h1 class="box" id="logo">Hi</h1>
CSS:
#logo { color: blue; }
.box { color: purple; } (a) blue (b) yellow (c) green (d) purple - 24.🔍 Which is the odd one out? (a) checks a quiz answer (b) changes the page live (c) reacts to a button click (d) changes the text size
- 25.Which of these does CSS do? (a) puts a picture on a page (b) makes a form box (c) sets colours and fonts (d) changes the page live
- 26.True or false: JavaScript checks a quiz answer. (a) False (b) True
- 27.🎯 Which element does the selector h2 style? (a) <div class="box"> (b) <span id="main"> (c) <li> (d) <h2 class="box">
- 28.✍️ How does a CSS comment start? (a) /* (b) <!-- (c) # (d) //
- 29.🌈 In #680000 the red part is the hex number 68. What is it as a normal number?
- 30.True or false: the content is the text or picture. (a) False (b) True
-
31.⚖️ What colour is the text of this element?
<h1 class="star" id="logo">Hi</h1>
CSS:
.star { color: green; }
h1 { color: red; } (a) purple (b) red (c) yellow (d) green -
32.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 220px;
justify-content: space-between;
}
Inside are 3 boxes, each 60px wide (no margins). -
33.⚖️ What colour is the text of this element?
<p class="big" id="logo">Hi</p>
CSS:
p { color: blue; }
p { color: red; } (a) blue (b) yellow (c) red (d) orange -
34.✍️ Which property is set to center in this rule?
#top {
border: 2px solid;
text-align: center;
} (a) center (b) background-color (c) margin (d) text-align -
35.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 280px;
padding: 5px;
border: 1px solid black;
margin: 10px;
} -
36.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 170px;
padding: 30px;
border: 3px solid black;
margin: 15px;
} -
37.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 10px;
}
} (a) Yes (b) No -
38.🖌️ How big is the text, in px?
h2 {
background-color: white;
font-size: 40px;
color: red;
text-align: right;
} - 39.🧩 Which language lays out the page? (a) HTML (b) CSS (c) JavaScript
-
40.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 270px;
justify-content: flex-start;
}
Inside are 4 boxes, each 60px wide (no margins).
Answer key
- a class selector
- 60
- cyan
- purple
- .menu
- a class selector
- makes a form box
- purple
- gives the page structure
- 40
- 600px or narrower
- blue
- Yes
- orange
- 342
- red
- content
- display: flex
- 20
- an element selector
- font-style
- adds space around boxes
- blue
- changes the text size
- sets colours and fonts
- True
- <h2 class="box">
- /*
- 104
- True
- green
- 20
- red
- text-align
- 312
- 266
- Yes
- 40
- CSS
- 30
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids