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.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 24px;
}
} - 2.💪 Which flexbox property turns on flexbox? (a) gap (b) flex-direction (c) justify-content (d) display: flex
-
3.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 20px;
}
} (a) No (b) Yes -
4.⚖️ What colour is the text of this element?
<h2 class="red" id="main">Hi</h2>
CSS:
h2 { color: white; }
h2 { color: red; } (a) red (b) yellow (c) purple (d) white - 5.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the later one (c) the first one (d) neither
-
6.🖌️ Where does the text sit on its line?
p {
font-size: 24px;
color: white;
background-color: yellow;
text-align: left;
} (a) on the left (b) on the right (c) in the middle -
7.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 290px;
padding: 10px;
border: 1px solid black;
margin: 10px;
} - 8.🖌️ Which CSS property makes the text bold? (a) font-weight (b) font-family (c) background-color (d) font-size
-
9.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 250px;
padding: 5px;
border: 4px solid black;
margin: 20px;
} - 10.💪 Which flexbox property sets space between boxes? (a) gap (b) display: flex (c) justify-content (d) flex-direction
-
11.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 24px;
}
} - 12.🌈 Which colour is rgb(0, 255, 0)? (a) red (b) blue (c) magenta (d) bright green
-
13.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 280px;
justify-content: flex-end;
}
Inside are 2 boxes, each 100px wide (no margins). - 14.🎯 Which element does the selector .star style? (a) <li class="note"> (b) <h2 class="star"> (c) <h2 class="menu"> (d) <h2 id="star">
-
15.✍️ What is the selector in this CSS rule?
#top {
padding: 8px;
border: 2px solid;
text-align: center;
} (a) li (b) 2px solid (c) #top (d) padding -
16.⚖️ What colour is the text of this element?
<p class="menu" id="hero">Hi</p>
CSS:
p { color: white; }
p { color: purple; } (a) purple (b) green (c) blue (d) white -
17.✍️ Which property is set to 20px in this rule?
body {
font-size: 20px;
border: 2px solid;
} (a) background-color (b) 20px (c) text-align (d) font-size -
18.🎯 Which CSS selector matches this element?
<li class="box" id="hero">Hello</li> (a) .hero (b) div (c) li (d) #box -
19.⚖️ What colour is the text of this element?
<h2 class="big" id="intro">Hi</h2>
CSS:
#intro { color: red; }
#intro { color: yellow; } (a) blue (b) purple (c) yellow (d) red -
20.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 8px;
}
} - 21.🎯 Which element does the selector .red style? (a) <h2 class="box"> (b) <li class="star"> (c) <h2 class="red"> (d) <h2 id="red">
- 22.🎨 Which tag holds CSS inside the head? (a) <style> (b) <script> (c) <body> (d) <css>
-
23.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 20px;
}
} -
24.🖌️ Where does the text sit on its line?
p {
background-color: red;
font-size: 12px;
text-align: left;
color: white;
} (a) in the middle (b) on the left (c) on the right - 25.🔍 Which is the odd one out? (a) counts down a timer (b) rounds box corners (c) shows a pop-up message (d) checks a quiz answer
- 26.🎯 What kind of selector is .star? (a) an element selector (b) a class selector (c) an id selector
-
27.💪 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). - 28.True or false: HTML counts down a timer. (a) False (b) True
-
29.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 10px;
}
} -
30.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 170px;
padding: 10px;
border: 5px solid black;
margin: 20px;
} - 31.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
-
32.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 480px) {
p {
font-size: 14px;
}
} -
33.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} (a) Yes (b) No - 34.What does font-family do? (a) centres a heading (b) makes the text bold (c) makes letters bigger (d) picks the font style
- 35.True or false: HTML puts a picture on a page. (a) True (b) False
-
36.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 120px;
padding: 10px;
border: 4px solid black;
margin: 20px;
} - 37.🎯 Which element does the selector .big style? (a) <p class="red"> (b) <h1 class="box"> (c) <p id="big"> (d) <p class="big">
-
38.✍️ What value is given to background-color in this rule?
#top {
background-color: yellow;
border: 2px solid;
width: 300px;
font-size: 20px;
} (a) 8px (b) background-color (c) 10px (d) yellow -
39.✍️ Which property is set to red in this rule?
p {
text-align: center;
color: red;
padding: 8px;
} (a) color (b) text-align (c) font-size (d) red - 40.🖌️ Which CSS property centres a heading? (a) font-size (b) text-align (c) color (d) font-family
Answer key
- 20
- display: flex
- Yes
- red
- the later one
- on the left
- 332
- font-weight
- 308
- gap
- 20
- bright green
- 80
- <h2 class="star">
- #top
- purple
- font-size
- li
- yellow
- 12
- <h2 class="red">
- <style>
- 20
- on the left
- rounds box corners
- a class selector
- 30
- False
- 12
- 240
- an id selector
- 16
- Yes
- picks the font style
- True
- 148
- <p class="big">
- yellow
- color
- text-align
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids