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.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 370px;
justify-content: space-between;
}
Inside are 4 boxes, each 40px wide (no margins). - 2.True or false: .card is an element selector. (a) True (b) False
- 3.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
-
4.🖌️ What colour is behind the letters?
h1 {
background-color: purple;
color: blue;
text-align: right;
font-size: 12px;
} (a) purple (b) orange (c) blue -
5.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 160px;
justify-content: flex-start;
}
Inside are 2 boxes, each 60px wide (no margins). - 6.📦 In the box model, which part is the text or picture? (a) content (b) margin (c) padding (d) border
- 7.🎯 Can many elements share the same class? (a) No (b) Yes
-
8.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 28px;
}
} - 9.What does font-weight do? (a) centres a heading (b) picks the font style (c) colours behind the text (d) makes the text bold
- 10.🧩 Which language sets colours and fonts? (a) HTML (b) JavaScript (c) CSS
-
11.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 50px;
padding: 15px;
border: 5px solid black;
margin: 15px;
} - 12.🔍 Which is the odd one out? (a) counts down a timer (b) changes the text size (c) checks a quiz answer (d) shows a pop-up message
- 13.✍️ In color: blue; which part is the value? (a) color (b) : (c) ; (d) blue
-
14.🖌️ How big is the text, in px?
p {
color: green;
text-align: right;
background-color: white;
font-size: 20px;
} - 15.🖌️ Which CSS property picks the font style? (a) font-size (b) font-weight (c) font-family (d) text-align
-
16.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 390px;
justify-content: flex-start;
}
Inside are 4 boxes, each 80px wide (no margins). -
17.✍️ What value is given to margin in this rule?
body {
background-color: yellow;
font-size: 20px;
margin: 10px;
} (a) margin (b) 8px (c) bold (d) 10px -
18.✍️ How many declarations (property: value pairs) are in this rule?
li {
border: 2px solid;
font-size: 20px;
font-style: italic;
color: red;
} - 19.What does justify-content: center 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
-
20.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 200px;
justify-content: center;
}
Inside are 3 boxes, each 60px wide (no margins). -
21.✍️ What value is given to background-color in this rule?
.note {
color: red;
background-color: yellow;
} (a) 10px (b) yellow (c) background-color (d) 8px -
22.⚖️ What colour is the text of this element?
<p class="menu" id="top">Hi</p>
CSS:
p { color: black; }
#top { color: yellow; } (a) black (b) white (c) yellow (d) orange - 23.💪 Which flexbox property turns on flexbox? (a) align-items (b) display: flex (c) flex-direction (d) gap
- 24.True or false: HTML makes headings and lists. (a) False (b) True
-
25.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 400px;
justify-content: flex-end;
}
Inside are 4 boxes, each 80px wide (no margins). -
26.✍️ What value is given to text-align in this rule?
body {
text-align: center;
margin: 10px;
} (a) text-align (b) 10px (c) center (d) yellow - 27.True or false: the content is the line round the box. (a) True (b) False
-
28.🖌️ What colour are the letters?
li {
text-align: center;
color: black;
background-color: orange;
font-size: 16px;
} (a) orange (b) yellow (c) black - 29.🌈 In #004f00 the green part is the hex number 4f. What is it as a normal number?
-
30.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 8px;
}
} -
31.✍️ What value is given to margin in this rule?
li {
margin: 10px;
font-style: italic;
width: 300px;
} (a) margin (b) 10px (c) bold (d) 8px -
32.⚖️ What colour is the text of this element?
<h2 class="red" id="intro">Hi</h2>
CSS:
.red { color: black; }
h2 { color: orange; }
#intro { color: green; } (a) orange (b) black (c) yellow (d) green -
33.⚖️ What colour is the text of this element?
<h2 class="note" id="main">Hi</h2>
CSS:
#main { color: green; }
h2 { color: orange; }
.note { color: purple; } (a) green (b) purple (c) orange (d) black - 34.What does font-family do? (a) colours behind the text (b) makes the text bold (c) picks the font style (d) centres a heading
- 35.True or false: the content is the gap round content. (a) False (b) True
- 36.True or false: JavaScript makes a link. (a) False (b) True
- 37.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
-
38.✍️ What is the selector in this CSS rule?
h1 {
padding: 8px;
width: 300px;
} (a) p (b) 300px (c) h1 (d) padding - 39.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) exactly 100px (c) 800px or wider (d) turned off
- 40.📦 In the box model, which part is the line round the box? (a) padding (b) margin (c) content (d) border
Answer key
- 70
- False
- an element selector
- purple
- 40
- content
- Yes
- 28
- makes the text bold
- CSS
- 120
- changes the text size
- blue
- 20
- font-family
- 70
- 10px
- 4
- puts boxes in the middle
- 10
- yellow
- yellow
- display: flex
- True
- 80
- center
- False
- black
- 79
- 8
- 10px
- green
- green
- picks the font style
- False
- False
- an id selector
- h1
- 800px or wider
- border
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids