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 much empty space (px) is left after the last box?
.row {
display: flex;
width: 230px;
justify-content: flex-start;
}
Inside are 4 boxes, each 40px wide (no margins). -
2.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 290px;
padding: 10px;
border: 1px solid black;
margin: 20px;
} -
3.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 220px;
justify-content: flex-start;
}
Inside are 2 boxes, each 80px wide (no margins). - 4.📦 In the box model, which part is space outside the border? (a) padding (b) border (c) margin (d) content
-
5.🎯 Which CSS selector matches this element?
<li class="box" id="hero">Hello</li> (a) #box (b) #top (c) div (d) li -
6.✍️ Which property is set to red in this rule?
.note {
border: 2px solid;
width: 300px;
padding: 8px;
color: red;
} (a) red (b) font-size (c) color (d) text-align - 7.🌈 In #0000ed the blue part is the hex number ed. What is it as a normal number?
-
8.✍️ How many declarations (property: value pairs) are in this rule?
li {
background-color: yellow;
text-align: center;
} - 9.Which of these is the border? (a) the gap to other boxes (b) the line round the box (c) space outside the border (d) the gap round content
-
10.🖌️ What colour is behind the letters?
h2 {
font-size: 28px;
text-align: center;
background-color: orange;
color: green;
} (a) purple (b) green (c) orange - 11.🎯 Which sign starts an id selector? (a) @ (b) # (c) & (d) .
-
12.📦 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;
} -
13.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 8px;
}
} (a) No (b) Yes - 14.🌈 In #0000e2 the blue part is the hex number e2. What is it as a normal number?
- 15.📦 In the box model, which part is the line round the box? (a) content (b) margin (c) padding (d) border
- 16.📦 In the box model, which part is the gap round content? (a) margin (b) border (c) content (d) padding
-
17.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 220px;
justify-content: space-between;
}
Inside are 3 boxes, each 40px wide (no margins). - 18.True or false: padding is space outside the border. (a) False (b) True
-
19.⚖️ What colour is the text of this element?
<p class="note" id="hero">Hi</p>
CSS:
.note { color: red; }
.note { color: orange; } (a) red (b) black (c) orange (d) yellow - 20.True or false: the border is a solid or dotted edge. (a) False (b) True
-
21.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 180px;
padding: 25px;
border: 2px solid black;
margin: 10px;
} - 22.🌈 Which colour is #0000ff? (a) red (b) yellow (c) blue (d) magenta
- 23.True or false: CSS gives the page structure. (a) True (b) False
-
24.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 250px;
padding: 15px;
border: 4px solid black;
margin: 20px;
} - 25.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
- 26.🌈 Which colour is #ffffff? (a) yellow (b) red (c) cyan (d) white
- 27.💪 Which justify-content value puts boxes in the middle? (a) flex-start (b) flex-end (c) space-between (d) center
- 28.🖌️ Which CSS property makes the text bold? (a) background-color (b) color (c) font-weight (d) font-family
-
29.⚖️ What colour is the text of this element?
<h1 class="red" id="top">Hi</h1>
CSS:
.red { color: red; }
.red { color: purple; } (a) purple (b) yellow (c) red (d) green - 30.True or false: margin is the gap to other boxes. (a) True (b) False
-
31.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 270px;
padding: 20px;
border: 3px solid black;
margin: 5px;
} - 32.What does font-family do? (a) centres a heading (b) makes letters bigger (c) colours behind the text (d) picks the font style
- 33.🎯 Which element does the selector h2 style? (a) <li> (b) <h2 class="box"> (c) <span id="main"> (d) <div class="box">
- 34.✍️ How does a CSS comment start? (a) // (b) # (c) /* (d) <!--
- 35.🌈 In #00e100 the green part is the hex number e1. What is it as a normal number?
- 36.🔍 Which is the odd one out? (a) reacts to a button click (b) puts a picture on a page (c) shows a pop-up message (d) changes the page live
-
37.✍️ How many declarations (property: value pairs) are in this rule?
body {
width: 300px;
font-weight: bold;
font-style: italic;
} - 38.True or false: JavaScript counts down a timer. (a) True (b) False
-
39.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 6px;
}
} - 40.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) blue (c) red (d) black
Answer key
- 70
- 352
- 60
- margin
- li
- color
- 237
- 2
- the line round the box
- orange
- #
- 120
- No
- 226
- border
- padding
- 50
- False
- orange
- True
- 254
- blue
- False
- 328
- an id selector
- white
- center
- font-weight
- purple
- True
- 326
- picks the font style
- <h2 class="box">
- /*
- 225
- puts a picture on a page
- 3
- True
- 12
- red
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids