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 does justify-content: center do? (a) puts boxes in the middle (b) packs boxes at the start (c) packs boxes at the end (d) equal gaps, none at ends
- 2.🖌️ Which CSS property colours behind the text? (a) font-weight (b) text-align (c) background-color (d) color
-
3.⚖️ What colour is the text of this element?
<p class="box" id="top">Hi</p>
CSS:
p { color: orange; }
p { color: white; } (a) blue (b) orange (c) purple (d) white -
4.⚖️ What colour is the text of this element?
<h1 class="menu" id="hero">Hi</h1>
CSS:
#hero { color: yellow; }
h1 { color: black; } (a) green (b) yellow (c) red (d) black - 5.✍️ CSS declarations go inside which brackets? (a) ( ) (b) { } (c) < > (d) [ ]
- 6.🧩 Which language changes the text size? (a) CSS (b) JavaScript (c) HTML
- 7.What does justify-content: flex-start do? (a) equal gaps, none at ends (b) packs boxes at the end (c) puts boxes in the middle (d) packs boxes at the start
- 8.💪 Which flexbox property lines boxes up across? (a) flex-direction (b) display: flex (c) align-items (d) justify-content
- 9.⚖️ 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
- 10.🎯 Which sign starts a class selector? (a) # (b) & (c) . (d) @
- 11.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
- 12.🔍 Which is the odd one out? (a) reacts to a button click (b) changes the text size (c) lays out the page (d) rounds box corners
- 13.True or false: padding is a solid or dotted edge. (a) False (b) True
- 14.🎯 Which element does the selector h2 style? (a) <div class="red"> (b) <li> (c) <span id="intro"> (d) <h2 class="red">
-
15.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 130px;
padding: 25px;
border: 5px solid black;
margin: 15px;
} -
16.🖌️ Where does the text sit on its line?
li {
color: white;
font-size: 28px;
text-align: center;
background-color: yellow;
} (a) on the right (b) on the left (c) in the middle - 17.🖌️ Which CSS property makes the text bold? (a) color (b) background-color (c) text-align (d) font-weight
-
18.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 320px;
justify-content: space-between;
}
Inside are 3 boxes, each 100px wide (no margins). -
19.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 280px;
padding: 15px;
border: 5px solid black;
margin: 0px;
} - 20.✍️ How does a CSS comment start? (a) /* (b) // (c) <!-- (d) #
-
21.⚖️ What colour is the text of this element?
<p class="red" id="logo">Hi</p>
CSS:
.red { color: purple; }
.red { color: black; } (a) yellow (b) purple (c) black (d) blue -
22.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 28px;
}
} -
23.✍️ What value is given to color in this rule?
.box {
text-align: center;
font-size: 20px;
font-weight: bold;
color: red;
} (a) color (b) 20px (c) red (d) center -
24.🖌️ How big is the text, in px?
li {
background-color: black;
text-align: right;
font-size: 36px;
color: green;
} - 25.🌈 Which colour is #ff0000? (a) red (b) magenta (c) blue (d) bright green
-
26.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 160px;
padding: 10px;
border: 1px solid black;
margin: 10px;
} -
27.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 210px;
padding: 5px;
border: 1px solid black;
margin: 20px;
} -
28.✍️ What is the selector in this CSS rule?
#top {
background-color: yellow;
font-style: italic;
border: 2px solid;
} (a) background-color (b) #top (c) li (d) italic -
29.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 22px;
}
} (a) Yes (b) No -
30.⚖️ What colour is the text of this element?
<h1 class="big" id="top">Hi</h1>
CSS:
#top { color: yellow; }
#top { color: black; } (a) yellow (b) red (c) white (d) black -
31.⚖️ What colour is the text of this element?
<p class="menu" id="hero">Hi</p>
CSS:
p { color: white; }
p { color: purple; } (a) yellow (b) white (c) red (d) purple - 32.True or false: .menu is an element selector. (a) True (b) False
-
33.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 10px;
}
} -
34.🖌️ How big is the text, in px?
li {
text-align: center;
color: blue;
font-size: 16px;
background-color: yellow;
} - 35.Which of these is padding? (a) space inside the border (b) the line round the box (c) the text or picture (d) space outside the border
- 36.🧩 Which language reacts to a button click? (a) JavaScript (b) CSS (c) HTML
- 37.🌈 Which hex code is cyan? (a) #0000ff (b) #ff0000 (c) #00ffff (d) #00ff00
- 38.✍️ Which sign goes between a property and its value? (a) ; (b) - (c) = (d) :
- 39.🌈 Which colour is rgb(0, 0, 0)? (a) black (b) red (c) magenta (d) cyan
-
40.🖌️ How big is the text, in px?
h2 {
background-color: red;
text-align: left;
font-size: 12px;
color: green;
}
Answer key
- puts boxes in the middle
- background-color
- white
- yellow
- { }
- CSS
- packs boxes at the start
- align-items
- the later one
- .
- an id selector
- reacts to a button click
- False
- <h2 class="red">
- 220
- in the middle
- font-weight
- 10
- 320
- /*
- black
- 20
- red
- 36
- red
- 202
- 262
- #top
- No
- black
- purple
- False
- 16
- 16
- space inside the border
- JavaScript
- #00ffff
- :
- black
- 12
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids