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) equal gaps, none at ends (b) packs boxes at the start (c) packs boxes at the end (d) puts boxes in the middle
- 2.🎯 Which element does the selector #end style? (a) <div class="end"> (b) <div id="end"> (c) <div id="hero"> (d) <span class="box">
- 3.💪 Which justify-content value puts boxes in the middle? (a) flex-start (b) center (c) space-between (d) flex-end
-
4.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 150px;
justify-content: flex-end;
}
Inside are 3 boxes, each 40px wide (no margins). -
5.✍️ How many declarations (property: value pairs) are in this rule?
li {
padding: 8px;
} - 6.🎯 Which element does the selector div style? (a) <h1 id="intro"> (b) <span> (c) <p class="big"> (d) <div class="big">
- 7.🌈 Which colour is #ffff00? (a) red (b) magenta (c) yellow (d) blue
- 8.✍️ Which sign goes between a property and its value? (a) = (b) : (c) - (d) ;
-
9.🖌️ What colour is behind the letters?
li {
background-color: green;
text-align: center;
color: red;
font-size: 28px;
} (a) green (b) red (c) yellow - 10.🎯 What kind of selector is .big? (a) a class selector (b) an id selector (c) an element selector
-
11.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 768px) {
p {
font-size: 14px;
}
} (a) Yes (b) No - 12.💪 Which flexbox property spaces boxes along a row? (a) display: flex (b) gap (c) flex-direction (d) justify-content
-
13.✍️ What value is given to width in this rule?
body {
width: 300px;
border: 2px solid;
font-weight: bold;
} (a) red (b) 300px (c) italic (d) width - 14.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) neither (c) the first one (d) the later one
- 15.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) white (c) blue (d) green
-
16.🖌️ Where does the text sit on its line?
h2 {
background-color: purple;
text-align: left;
font-size: 32px;
color: red;
} (a) in the middle (b) on the right (c) on the left - 17.🌈 In #rrggbb, which colour do the first two digits give? (a) red (b) blue (c) green (d) black
- 18.🎯 What kind of selector is body? (a) a class selector (b) an id selector (c) an element selector
- 19.💪 Which flexbox property sets space between boxes? (a) display: flex (b) justify-content (c) flex-direction (d) gap
-
20.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 450px;
justify-content: space-between;
}
Inside are 4 boxes, each 60px wide (no margins). - 21.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
- 22.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) 800px or narrower (c) 800px or wider (d) exactly 100px
-
23.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 18px;
}
} (a) Yes (b) No - 24.🎨 Which tag connects an outside CSS file? (a) <a> (b) <css> (c) <link> (d) <img>
- 25.True or false: HTML makes headings and lists. (a) True (b) False
-
26.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 160px;
justify-content: center;
}
Inside are 2 boxes, each 50px wide (no margins). - 27.🧩 Which language puts a picture on a page? (a) CSS (b) HTML (c) JavaScript
-
28.⚖️ What colour is the text of this element?
<h2 class="big" id="top">Hi</h2>
CSS:
h2 { color: orange; }
.big { color: red; }
#top { color: black; } (a) red (b) orange (c) green (d) black - 29.🧩 Which language makes a form box? (a) HTML (b) JavaScript (c) CSS
- 30.📱 What does a media query check? (a) the time of day (b) the screen width (c) the battery level (d) the page title
-
31.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 150px;
padding: 15px;
border: 5px solid black;
margin: 0px;
} -
32.🖌️ Where does the text sit on its line?
p {
text-align: left;
background-color: black;
font-size: 20px;
color: white;
} (a) in the middle (b) on the left (c) on the right -
33.✍️ How many declarations (property: value pairs) are in this rule?
.box {
font-style: italic;
color: red;
} -
34.🖌️ What colour is behind the letters?
p {
font-size: 12px;
text-align: right;
background-color: red;
color: black;
} (a) red (b) orange (c) black - 35.🌈 Which hex code is yellow? (a) #ff00ff (b) #ffff00 (c) #ffffff (d) #000000
-
36.✍️ What is the selector in this CSS rule?
li {
font-size: 20px;
text-align: center;
padding: 8px;
} (a) li (b) font-size (c) center (d) body - 37.🌈 Which colour is rgb(0, 0, 255)? (a) red (b) bright green (c) blue (d) cyan
- 38.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
-
39.🎯 Which CSS selector matches this element?
<li class="star" id="main">Hello</li> (a) .menu (b) #star (c) div (d) li - 40.📦 In the box model, which part is the text or picture? (a) content (b) border (c) margin (d) padding
Answer key
- packs boxes at the start
- <div id="end">
- center
- 30
- 1
- <div class="big">
- yellow
- :
- green
- a class selector
- No
- justify-content
- 300px
- the later one
- blue
- on the left
- red
- an element selector
- gap
- 70
- an id selector
- 800px or wider
- Yes
- <link>
- True
- 30
- HTML
- black
- HTML
- the screen width
- 190
- on the left
- 2
- red
- #ffff00
- li
- blue
- an element selector
- li
- content
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids