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: 90px;
justify-content: flex-start;
}
Inside are 2 boxes, each 40px wide (no margins). - 2.True or false: CSS adds space around boxes. (a) True (b) False
-
3.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 280px;
justify-content: flex-start;
}
Inside are 4 boxes, each 60px wide (no margins). -
4.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 240px;
padding: 25px;
border: 2px solid black;
margin: 0px;
} - 5.🌈 Which colour of light is strongest in rgb(136, 71, 230)? (a) red (b) green (c) blue
- 6.✍️ Which sign goes between a property and its value? (a) ; (b) : (c) - (d) =
-
7.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 40px;
padding: 25px;
border: 3px solid black;
margin: 10px;
} -
8.🖌️ How big is the text, in px?
h1 {
text-align: center;
background-color: red;
color: green;
font-size: 36px;
} -
9.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 768px) {
p {
font-size: 28px;
}
} -
10.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 180px;
justify-content: center;
}
Inside are 2 boxes, each 80px wide (no margins). - 11.💪 Which justify-content value puts boxes in the middle? (a) space-between (b) flex-end (c) flex-start (d) center
-
12.✍️ What is the selector in this CSS rule?
.note {
font-style: italic;
font-size: 20px;
color: red;
border: 2px solid;
} (a) font-style (b) 20px (c) #top (d) .note -
13.🖌️ Where does the text sit on its line?
p {
font-size: 24px;
text-align: center;
background-color: orange;
color: white;
} (a) in the middle (b) on the right (c) on the left -
14.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 1024px) {
p {
font-size: 32px;
}
} (a) Yes (b) No -
15.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} -
16.✍️ What is the selector in this CSS rule?
li {
padding: 8px;
width: 300px;
color: red;
} (a) body (b) padding (c) li (d) 300px -
17.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
font-weight: bold;
padding: 8px;
color: red;
} -
18.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 100px;
padding: 25px;
border: 1px solid black;
margin: 0px;
} -
19.🎯 Which CSS selector matches this element?
<li class="menu" id="end">Hello</li> (a) .end (b) #hero (c) #end (d) #menu -
20.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 270px;
padding: 20px;
border: 5px solid black;
margin: 5px;
} -
21.🎯 Which CSS selector matches this element?
<span class="star" id="top">Hello</span> (a) span (b) #intro (c) #star (d) .menu -
22.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 1024px) {
p {
font-size: 24px;
}
} (a) No (b) Yes - 23.📦 In the box model, which part is the text or picture? (a) border (b) content (c) margin (d) padding
-
24.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 270px;
justify-content: flex-start;
}
Inside are 2 boxes, each 100px wide (no margins). - 25.🖌️ Which CSS property picks the font style? (a) background-color (b) text-align (c) font-family (d) color
-
26.🖌️ What colour is behind the letters?
h2 {
font-size: 36px;
text-align: right;
color: black;
background-color: orange;
} (a) orange (b) black (c) blue -
27.⚖️ What colour is the text of this element?
<h1 class="box" id="hero">Hi</h1>
CSS:
#hero { color: purple; }
.box { color: green; }
h1 { color: white; } (a) green (b) purple (c) orange (d) white -
28.🎯 Which CSS selector matches this element?
<li class="red" id="intro">Hello</li> (a) .red (b) div (c) .intro (d) #red - 29.True or false: the border is the line round the box. (a) True (b) False
- 30.Which of these does CSS do? (a) makes a link (b) lays out the page (c) reacts to a button click (d) gives the page structure
- 31.📦 In the box model, which part is space inside the border? (a) margin (b) padding (c) content (d) border
-
32.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 768px) {
p {
font-size: 28px;
}
} (a) No (b) Yes -
33.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 14px;
}
} (a) Yes (b) No - 34.True or false: the border is the gap to other boxes. (a) False (b) True
- 35.True or false: margin is space outside the border. (a) False (b) True
- 36.✍️ Which sign ends each CSS declaration? (a) ; (b) . (c) , (d) :
-
37.🖌️ Where does the text sit on its line?
li {
text-align: right;
color: black;
background-color: yellow;
font-size: 28px;
} (a) on the right (b) on the left (c) in the middle -
38.🎯 Which CSS selector matches this element?
<p class="note" id="hero">Hello</p> (a) .big (b) .note (c) h1 (d) #note - 39.🌈 Which colour is rgb(0, 0, 0)? (a) cyan (b) blue (c) black (d) magenta
- 40.🎯 Which element does the selector .note style? (a) <span class="red"> (b) <div class="big"> (c) <div id="note"> (d) <div class="note">
Answer key
- 10
- True
- 40
- 294
- blue
- :
- 116
- 36
- 24
- 10
- center
- .note
- in the middle
- No
- 10
- li
- 3
- 152
- #end
- 330
- span
- No
- content
- 70
- font-family
- orange
- purple
- .red
- True
- lays out the page
- padding
- Yes
- Yes
- False
- True
- ;
- on the right
- .note
- black
- <div class="note">
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids