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.✍️ What value is given to padding in this rule?
.box {
text-align: center;
width: 300px;
padding: 8px;
} (a) bold (b) 8px (c) 2px solid (d) padding -
2.⚖️ What colour is the text of this element?
<h2 class="note" id="main">Hi</h2>
CSS:
h2 { color: white; }
#main { color: green; } (a) red (b) green (c) white (d) yellow -
3.⚖️ What colour is the text of this element?
<p class="menu" id="main">Hi</p>
CSS:
p { color: white; }
.menu { color: black; } (a) red (b) black (c) white (d) purple - 4.🌈 Which hex code is red? (a) #00ff00 (b) #000000 (c) #ff0000 (d) #ffffff
- 5.🧩 Which language puts a picture on a page? (a) HTML (b) JavaScript (c) CSS
-
6.⚖️ What colour is the text of this element?
<p class="note" id="logo">Hi</p>
CSS:
p { color: yellow; }
p { color: black; } (a) black (b) purple (c) red (d) yellow - 7.What does justify-content: space-between do? (a) packs boxes at the end (b) packs boxes at the start (c) equal gaps, none at ends (d) puts boxes in the middle
-
8.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 100px;
justify-content: flex-start;
}
Inside are 2 boxes, each 40px wide (no margins). -
9.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 520px;
justify-content: space-between;
}
Inside are 4 boxes, each 100px wide (no margins). - 10.🎯 Which sign starts a class selector? (a) . (b) @ (c) # (d) &
- 11.✍️ Which sign goes between a property and its value? (a) ; (b) = (c) - (d) :
-
12.✍️ How many declarations (property: value pairs) are in this rule?
li {
width: 300px;
font-style: italic;
font-size: 20px;
} -
13.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 190px;
justify-content: space-between;
}
Inside are 2 boxes, each 80px wide (no margins). -
14.🖌️ Where does the text sit on its line?
p {
font-size: 16px;
background-color: black;
color: white;
text-align: center;
} (a) on the right (b) in the middle (c) on the left -
15.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 16px;
}
} - 16.What does justify-content: center do? (a) puts boxes in the middle (b) packs boxes at the end (c) packs boxes at the start (d) equal gaps, none at ends
-
17.📦 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: 5px;
border: 4px solid black;
margin: 15px;
} -
18.⚖️ What colour is the text of this element?
<h2 class="red" id="main">Hi</h2>
CSS:
#main { color: white; }
#main { color: blue; } (a) purple (b) red (c) white (d) blue -
19.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 30px;
}
} -
20.✍️ Which property is set to yellow in this rule?
h1 {
margin: 10px;
background-color: yellow;
font-style: italic;
} (a) padding (b) background-color (c) margin (d) yellow - 21.What does background-color do? (a) makes letters bigger (b) centres a heading (c) sets the letter colour (d) colours behind the text
- 22.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
-
23.🖌️ What colour are the letters?
p {
background-color: black;
font-size: 12px;
text-align: left;
color: yellow;
} (a) yellow (b) black (c) purple -
24.✍️ What is the selector in this CSS rule?
li {
font-style: italic;
font-weight: bold;
text-align: center;
font-size: 20px;
} (a) bold (b) body (c) font-style (d) li -
25.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 18px;
}
} (a) No (b) Yes -
26.🖌️ What colour are the letters?
h2 {
font-size: 16px;
background-color: green;
text-align: right;
color: red;
} (a) purple (b) green (c) red -
27.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 140px;
justify-content: flex-start;
}
Inside are 2 boxes, each 50px wide (no margins). - 28.🌈 Which colour is #00ff00? (a) black (b) yellow (c) bright green (d) cyan
-
29.🖌️ Where does the text sit on its line?
h2 {
background-color: yellow;
text-align: right;
font-size: 24px;
color: green;
} (a) on the left (b) on the right (c) in the middle - 30.Which of these is margin? (a) a solid or dotted edge (b) space outside the border (c) the gap round content (d) space inside the border
- 31.Which of these does JavaScript do? (a) checks a quiz answer (b) lays out the page (c) gives the page structure (d) changes the text size
-
32.✍️ Which property is set to red in this rule?
.box {
text-align: center;
color: red;
} (a) color (b) font-size (c) red (d) text-align - 33.🌈 Which hex code is yellow? (a) #000000 (b) #ffffff (c) #00ffff (d) #ffff00
- 34.✍️ In color: blue; which part is the property? (a) : (b) blue (c) color (d) ;
- 35.💪 Which flexbox property lines boxes up across? (a) flex-direction (b) justify-content (c) gap (d) align-items
-
36.⚖️ What colour is the text of this element?
<h2 class="box" id="top">Hi</h2>
CSS:
.box { color: purple; }
h2 { color: white; } (a) white (b) purple (c) yellow (d) blue -
37.✍️ How many declarations (property: value pairs) are in this rule?
.note {
font-weight: bold;
font-size: 20px;
color: red;
} - 38.What does font-weight do? (a) makes the text bold (b) centres a heading (c) sets the letter colour (d) picks the font style
-
39.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 18px;
}
} - 40.💪 Which flexbox property sets space between boxes? (a) justify-content (b) align-items (c) display: flex (d) gap
Answer key
- 8px
- green
- black
- #ff0000
- HTML
- black
- equal gaps, none at ends
- 20
- 40
- .
- :
- 3
- 30
- in the middle
- 20
- puts boxes in the middle
- 138
- blue
- 30
- background-color
- colours behind the text
- an element selector
- yellow
- li
- No
- red
- 40
- bright green
- on the right
- space outside the border
- checks a quiz answer
- color
- #ffff00
- color
- align-items
- purple
- 3
- makes the text bold
- 18
- gap
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids