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 does justify-content: flex-start do? (a) puts boxes in the middle (b) equal gaps, none at ends (c) packs boxes at the end (d) packs boxes at the start
-
2.⚖️ What colour is the text of this element?
<p class="star" id="main">Hi</p>
CSS:
#main { color: white; }
#main { color: yellow; } (a) red (b) yellow (c) white (d) purple - 3.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 2 (b) 6 (c) 3 (d) 4
-
4.✍️ What is the selector in this CSS rule?
h2 {
padding: 8px;
width: 300px;
} (a) 300px (b) h2 (c) h1 (d) padding -
5.⚖️ What colour is the text of this element?
<h1 class="star" id="hero">Hi</h1>
CSS:
.star { color: white; }
.star { color: red; } (a) white (b) orange (c) red (d) green -
6.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 380px;
justify-content: center;
}
Inside are 4 boxes, each 60px wide (no margins). - 7.What does color do? (a) makes letters bigger (b) makes the text bold (c) sets the letter colour (d) centres a heading
- 8.🧩 Which language makes headings and lists? (a) HTML (b) CSS (c) JavaScript
- 9.🔍 Which is the odd one out? (a) changes the page live (b) lays out the page (c) sets colours and fonts (d) adds space around boxes
- 10.📱 min-width: 800px applies when the screen is ___. (a) 800px or wider (b) 800px or narrower (c) exactly 100px (d) turned off
-
11.🖌️ What colour is behind the letters?
h1 {
background-color: white;
color: blue;
text-align: right;
font-size: 40px;
} (a) red (b) white (c) blue - 12.🖌️ Which CSS property sets the letter colour? (a) text-align (b) color (c) font-size (d) background-color
- 13.🎯 Which element does the selector p style? (a) <h2 class="note"> (b) <p class="note"> (c) <h1> (d) <li id="hero">
-
14.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 26px;
}
} (a) No (b) Yes - 15.🎯 Which element does the selector h2 style? (a) <li> (b) <span id="logo"> (c) <h2 class="star"> (d) <div class="star">
- 16.What does text-align do? (a) colours behind the text (b) centres a heading (c) makes the text bold (d) sets the letter colour
- 17.🧩 Which language counts down a timer? (a) HTML (b) CSS (c) JavaScript
- 18.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the later one (c) the first one (d) the shorter one
-
19.⚖️ What colour is the text of this element?
<h1 class="menu" id="end">Hi</h1>
CSS:
.menu { color: white; }
.menu { color: red; } (a) red (b) white (c) orange (d) black - 20.Which of these does CSS do? (a) makes a form box (b) reacts to a button click (c) puts a picture on a page (d) sets colours and fonts
- 21.🌈 In #d10000 the red part is the hex number d1. What is it as a normal number?
-
22.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 14px;
}
} - 23.Which of these is the border? (a) the gap to other boxes (b) the text or picture (c) space inside the border (d) the line round the box
- 24.🎯 What kind of selector is li? (a) an id selector (b) a class selector (c) an element selector
-
25.⚖️ What colour is the text of this element?
<h1 class="menu" id="intro">Hi</h1>
CSS:
.menu { color: red; }
.menu { color: purple; } (a) purple (b) red (c) green (d) white - 26.🌈 Which colour is #00ffff? (a) bright green (b) cyan (c) magenta (d) blue
- 27.What does justify-content: flex-end do? (a) packs boxes at the start (b) packs boxes at the end (c) equal gaps, none at ends (d) puts boxes in the middle
- 28.✍️ How does a CSS comment start? (a) // (b) /* (c) <!-- (d) #
- 29.🌈 Which colour is rgb(255, 0, 0)? (a) bright green (b) magenta (c) blue (d) red
- 30.🌈 Which hex code is red? (a) #ffff00 (b) #00ffff (c) #ff0000 (d) #000000
- 31.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
- 32.💪 Which flexbox property turns on flexbox? (a) gap (b) align-items (c) display: flex (d) justify-content
-
33.⚖️ What colour is the text of this element?
<h1 class="big" id="logo">Hi</h1>
CSS:
#logo { color: purple; }
#logo { color: orange; } (a) green (b) orange (c) purple (d) red - 34.🌈 Which hex code is magenta? (a) #ffffff (b) #ffff00 (c) #ff00ff (d) #ff0000
- 35.🔍 Which is the odd one out? (a) makes headings and lists (b) puts a picture on a page (c) gives the page structure (d) checks a quiz answer
-
36.✍️ Which property is set to red in this rule?
li {
width: 300px;
color: red;
text-align: center;
} (a) text-align (b) font-size (c) red (d) color - 37.🌈 Which colour is #ffff00? (a) red (b) blue (c) cyan (d) yellow
- 38.🎯 Can many elements share the same class? (a) No (b) Yes
- 39.🧩 Which language gives the page structure? (a) HTML (b) JavaScript (c) CSS
-
40.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 40px;
padding: 20px;
border: 4px solid black;
margin: 0px;
}
Answer key
- packs boxes at the start
- yellow
- 3
- h2
- red
- 70
- sets the letter colour
- HTML
- changes the page live
- 800px or wider
- white
- color
- <p class="note">
- No
- <h2 class="star">
- centres a heading
- JavaScript
- the later one
- red
- sets colours and fonts
- 209
- 14
- the line round the box
- an element selector
- purple
- cyan
- packs boxes at the end
- /*
- red
- #ff0000
- an element selector
- display: flex
- orange
- #ff00ff
- checks a quiz answer
- color
- yellow
- Yes
- HTML
- 88
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids