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 wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 300px;
padding: 10px;
border: 1px solid black;
margin: 15px;
} - 2.💪 Which justify-content value packs boxes at the start? (a) space-between (b) flex-start (c) center (d) flex-end
- 3.🌈 In #010000 the red part is the hex number 01. What is it as a normal number?
- 4.🎯 Which element does the selector .star style? (a) <div class="menu"> (b) <div id="star"> (c) <div class="star"> (d) <span class="note">
- 5.🌈 Which colour is #00ff00? (a) black (b) blue (c) red (d) bright green
- 6.💪 Which justify-content value packs boxes at the end? (a) space-between (b) flex-start (c) center (d) flex-end
-
7.💪 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). -
8.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 14px;
}
} (a) Yes (b) No - 9.📱 What does a media query check? (a) the screen width (b) the page title (c) the time of day (d) the battery level
- 10.True or false: HTML changes the page live. (a) True (b) False
- 11.🌈 Which hex code is white? (a) #ff0000 (b) #0000ff (c) #ffffff (d) #ffff00
-
12.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 250px;
padding: 30px;
border: 4px solid black;
margin: 20px;
} - 13.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
- 14.💪 Which flexbox property spaces boxes along a row? (a) flex-direction (b) align-items (c) display: flex (d) justify-content
- 15.What does text-align do? (a) sets the letter colour (b) picks the font style (c) colours behind the text (d) centres a heading
-
16.✍️ Which property is set to 8px in this rule?
.note {
color: red;
padding: 8px;
} (a) border (b) 8px (c) padding (d) font-weight -
17.🖌️ Where does the text sit on its line?
h1 {
text-align: right;
font-size: 24px;
background-color: white;
color: green;
} (a) in the middle (b) on the left (c) on the right -
18.✍️ How many declarations (property: value pairs) are in this rule?
.note {
text-align: center;
} -
19.✍️ How many declarations (property: value pairs) are in this rule?
body {
background-color: yellow;
} - 20.💪 Which flexbox property picks row or column? (a) align-items (b) justify-content (c) gap (d) flex-direction
-
21.⚖️ What colour is the text of this element?
<p class="red" id="intro">Hi</p>
CSS:
p { color: green; }
#intro { color: orange; }
.red { color: blue; } (a) blue (b) green (c) yellow (d) orange - 22.🎯 Which sign starts an id selector? (a) # (b) . (c) & (d) @
-
23.🖌️ What colour is behind the letters?
h1 {
background-color: red;
text-align: left;
font-size: 20px;
color: green;
} (a) yellow (b) green (c) red -
24.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 160px;
justify-content: flex-start;
}
Inside are 2 boxes, each 40px wide (no margins). -
25.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 120px;
padding: 5px;
border: 3px solid black;
margin: 20px;
} - 26.📦 In the box model, which part is the text or picture? (a) padding (b) content (c) border (d) margin
- 27.Which of these does CSS do? (a) makes a link (b) checks a quiz answer (c) lays out the page (d) counts down a timer
-
28.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 560px;
justify-content: space-between;
}
Inside are 4 boxes, each 80px wide (no margins). - 29.✍️ CSS declarations go inside which brackets? (a) ( ) (b) < > (c) { } (d) [ ]
- 30.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 4 (b) 3 (c) 6 (d) 2
-
31.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 22px;
}
} - 32.🔍 Which is the odd one out? (a) changes the page live (b) adds space around boxes (c) counts down a timer (d) checks a quiz answer
- 33.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the later one (c) neither (d) the shorter one
- 34.Which of these is margin? (a) a solid or dotted edge (b) the gap to other boxes (c) the line round the box (d) the gap round content
- 35.What does justify-content: flex-start 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
- 36.True or false: the content is space outside the border. (a) True (b) False
- 37.🌈 Which colour is rgb(0, 0, 255)? (a) bright green (b) yellow (c) white (d) blue
- 38.🎯 Which element does the selector #hero style? (a) <h2 class="box"> (b) <h1 id="hero"> (c) <h1 id="top"> (d) <h1 class="hero">
- 39.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) exactly 100px (c) turned off (d) 800px or wider
- 40.✍️ Which sign goes between a property and its value? (a) : (b) - (c) ; (d) =
Answer key
- 322
- flex-start
- 1
- <div class="star">
- bright green
- flex-end
- 70
- Yes
- the screen width
- False
- #ffffff
- 318
- an element selector
- justify-content
- centres a heading
- padding
- on the right
- 1
- 1
- flex-direction
- orange
- #
- red
- 80
- 176
- content
- lays out the page
- 80
- { }
- 3
- 22
- adds space around boxes
- the later one
- the gap to other boxes
- packs boxes at the start
- False
- blue
- <h1 id="hero">
- 800px or wider
- :
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids