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 space top to bottom (px) does this box take in all, margin included?
.box {
height: 160px;
padding: 10px;
border: 3px solid black;
margin: 10px;
} -
2.🎯 Which CSS selector matches this element?
<h2 class="menu" id="hero">Hello</h2> (a) #menu (b) .hero (c) h2 (d) .note - 3.✍️ Which sign goes between a property and its value? (a) - (b) ; (c) = (d) :
- 4.📦 In the box model, which part is the gap to other boxes? (a) content (b) padding (c) border (d) margin
- 5.Which of these is margin? (a) a solid or dotted edge (b) space inside the border (c) the line round the box (d) space outside the border
- 6.True or false: padding is the gap round content. (a) True (b) False
-
7.✍️ How many declarations (property: value pairs) are in this rule?
li {
text-align: center;
background-color: yellow;
margin: 10px;
} - 8.🎯 Which element does the selector #logo style? (a) <h2 id="end"> (b) <li class="red"> (c) <h2 id="logo"> (d) <h2 class="logo">
-
9.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: flex-end;
}
Inside are 4 boxes, each 50px wide (no margins). - 10.🧩 Which language checks a quiz answer? (a) CSS (b) JavaScript (c) HTML
-
11.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 22px;
}
} (a) No (b) Yes -
12.✍️ What is the selector in this CSS rule?
h2 {
color: red;
font-size: 20px;
background-color: yellow;
font-style: italic;
} (a) color (b) h2 (c) h1 (d) 20px - 13.💪 Which flexbox property turns on flexbox? (a) justify-content (b) align-items (c) display: flex (d) flex-direction
-
14.✍️ What is the selector in this CSS rule?
.box {
font-style: italic;
border: 2px solid;
font-size: 20px;
} (a) 2px solid (b) font-style (c) h2 (d) .box -
15.🖌️ Where does the text sit on its line?
li {
background-color: red;
color: orange;
font-size: 20px;
text-align: right;
} (a) on the right (b) in the middle (c) on the left - 16.True or false: CSS puts a picture on a page. (a) False (b) True
-
17.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
text-align: center;
color: red;
margin: 10px;
border: 2px solid;
} -
18.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 200px;
justify-content: flex-start;
}
Inside are 2 boxes, each 60px wide (no margins). -
19.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 140px;
padding: 15px;
border: 3px solid black;
margin: 0px;
} - 20.🎯 What kind of selector is .big? (a) a class selector (b) an id selector (c) an element selector
-
21.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 1024px) {
p {
font-size: 14px;
}
} - 22.✍️ In color: blue; which part is the property? (a) blue (b) color (c) ; (d) :
- 23.🧩 Which language changes the page live? (a) CSS (b) JavaScript (c) HTML
-
24.⚖️ What colour is the text of this element?
<h2 class="box" id="top">Hi</h2>
CSS:
.box { color: white; }
.box { color: green; } (a) yellow (b) white (c) green (d) orange - 25.🎯 Can many elements share the same class? (a) No (b) Yes
-
26.✍️ How many declarations (property: value pairs) are in this rule?
li {
width: 300px;
background-color: yellow;
font-weight: bold;
} -
27.🖌️ What colour is behind the letters?
p {
font-size: 40px;
color: yellow;
background-color: green;
text-align: left;
} (a) yellow (b) green (c) white - 28.💪 Which justify-content value puts boxes in the middle? (a) flex-start (b) flex-end (c) center (d) space-between
-
29.✍️ How many declarations (property: value pairs) are in this rule?
#top {
padding: 8px;
} -
30.🎯 Which CSS selector matches this element?
<span class="menu" id="intro">Hello</span> (a) .menu (b) .note (c) p (d) .intro -
31.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} (a) No (b) Yes - 32.🌈 In #000300 the green part is the hex number 03. What is it as a normal number?
- 33.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 3 (b) 6 (c) 2 (d) 4
- 34.True or false: .star is an id selector. (a) True (b) False
- 35.What does justify-content: center do? (a) packs boxes at the start (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the end
-
36.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 280px;
padding: 20px;
border: 3px solid black;
margin: 15px;
} - 37.🌈 Which colour is #ffffff? (a) blue (b) red (c) white (d) black
-
38.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} (a) No (b) Yes -
39.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 190px;
justify-content: flex-end;
}
Inside are 4 boxes, each 40px wide (no margins). -
40.⚖️ What colour is the text of this element?
<p class="menu" id="logo">Hi</p>
CSS:
p { color: orange; }
p { color: black; } (a) white (b) orange (c) black (d) blue
Answer key
- 206
- h2
- :
- margin
- space outside the border
- True
- 3
- <h2 id="logo">
- 60
- JavaScript
- No
- h2
- display: flex
- .box
- on the right
- False
- 4
- 80
- 176
- a class selector
- 20
- color
- JavaScript
- green
- Yes
- 3
- green
- center
- 1
- .menu
- Yes
- 3
- 3
- False
- puts boxes in the middle
- 356
- white
- Yes
- 30
- black
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids