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.🌈 Which hex code is blue? (a) #ff0000 (b) #ff00ff (c) #ffff00 (d) #0000ff
-
2.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 768px) {
p {
font-size: 32px;
}
} (a) No (b) Yes -
3.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 600px) {
p {
font-size: 26px;
}
} -
4.⚖️ What colour is the text of this element?
<h2 class="red" id="intro">Hi</h2>
CSS:
#intro { color: green; }
h2 { color: orange; }
.red { color: black; } (a) yellow (b) green (c) black (d) orange -
5.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 360px;
justify-content: center;
}
Inside are 2 boxes, each 100px wide (no margins). - 6.Which of these does CSS do? (a) reacts to a button click (b) checks a quiz answer (c) sets colours and fonts (d) makes a form box
- 7.🧩 Which language makes a form box? (a) JavaScript (b) CSS (c) HTML
-
8.⚖️ What colour is the text of this element?
<h1 class="box" id="top">Hi</h1>
CSS:
.box { color: blue; }
h1 { color: yellow; }
#top { color: black; } (a) blue (b) black (c) yellow (d) red -
9.🖌️ Where does the text sit on its line?
h2 {
background-color: yellow;
text-align: center;
font-size: 20px;
color: green;
} (a) in the middle (b) on the left (c) on the right -
10.🖌️ Where does the text sit on its line?
h2 {
font-size: 24px;
text-align: center;
background-color: orange;
color: white;
} (a) in the middle (b) on the right (c) on the left - 11.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) exactly 1000px (c) turned off (d) 600px or narrower
-
12.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 18px;
}
} (a) No (b) Yes - 13.🌈 Which hex code is cyan? (a) #00ff00 (b) #0000ff (c) #00ffff (d) #ff0000
- 14.💪 Which flexbox property sets space between boxes? (a) flex-direction (b) gap (c) justify-content (d) align-items
- 15.🎯 What kind of selector is #top? (a) an id selector (b) an element selector (c) a class selector
-
16.🎯 Which CSS selector matches this element?
<span class="star" id="intro">Hello</span> (a) p (b) #intro (c) #star (d) #main -
17.🖌️ What colour are the letters?
h1 {
color: green;
background-color: orange;
font-size: 40px;
text-align: right;
} (a) yellow (b) green (c) orange -
18.⚖️ What colour is the text of this element?
<p class="big" id="top">Hi</p>
CSS:
#top { color: red; }
#top { color: green; } (a) black (b) green (c) red (d) white - 19.Which of these does HTML do? (a) counts down a timer (b) shows a pop-up message (c) lays out the page (d) makes a link
- 20.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
- 21.📱 Which tag helps phones show a page at the right size? (a) the br tag (b) the viewport meta tag (c) the title tag (d) the hr tag
-
22.⚖️ What colour is the text of this element?
<h2 class="note" id="logo">Hi</h2>
CSS:
h2 { color: red; }
#logo { color: white; }
.note { color: yellow; } (a) red (b) yellow (c) black (d) white - 23.💪 Which justify-content value packs boxes at the end? (a) space-between (b) flex-end (c) center (d) flex-start
- 24.📱 What does a media query check? (a) the time of day (b) the screen width (c) the battery level (d) the page title
- 25.What does justify-content: space-between 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
-
26.⚖️ What colour is the text of this element?
<h2 class="star" id="logo">Hi</h2>
CSS:
.star { color: green; }
#logo { color: red; } (a) green (b) purple (c) white (d) red -
27.✍️ What value is given to font-style in this rule?
body {
font-style: italic;
width: 300px;
background-color: yellow;
} (a) red (b) 20px (c) italic (d) font-style - 28.True or false: margin is a solid or dotted edge. (a) True (b) False
- 29.📱 Responsive design means a page ___. (a) fits every screen (b) never changes (c) has no pictures (d) is only for laptops
-
30.📦 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: 25px;
border: 5px solid black;
margin: 10px;
} -
31.✍️ How many declarations (property: value pairs) are in this rule?
#top {
font-weight: bold;
border: 2px solid;
text-align: center;
width: 300px;
} -
32.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 12px;
}
} -
33.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 18px;
}
} - 34.🎯 Which sign starts a class selector? (a) @ (b) & (c) # (d) .
- 35.🔍 Which is the odd one out? (a) adds space around boxes (b) sets colours and fonts (c) puts a picture on a page (d) rounds box corners
- 36.🎯 Can many elements share the same class? (a) Yes (b) No
-
37.✍️ What is the selector in this CSS rule?
li {
width: 300px;
text-align: center;
background-color: yellow;
border: 2px solid;
} (a) li (b) width (c) body (d) center -
38.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} -
39.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} (a) Yes (b) No - 40.🎯 What kind of selector is #main? (a) an id selector (b) an element selector (c) a class selector
Answer key
- #0000ff
- No
- 26
- green
- 80
- sets colours and fonts
- HTML
- black
- in the middle
- in the middle
- 600px or narrower
- No
- #00ffff
- gap
- an id selector
- #intro
- green
- green
- makes a link
- an element selector
- the viewport meta tag
- white
- flex-end
- the screen width
- equal gaps, none at ends
- red
- italic
- False
- fits every screen
- 310
- 4
- 12
- 18
- .
- puts a picture on a page
- Yes
- li
- 18
- No
- an id selector
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids