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: 230px;
justify-content: flex-start;
}
Inside are 4 boxes, each 40px wide (no margins). -
2.🎯 Which CSS selector matches this element?
<h1 class="star" id="top">Hello</h1> (a) h1 (b) .top (c) #intro (d) h2 -
3.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 190px;
justify-content: flex-end;
}
Inside are 3 boxes, each 60px wide (no margins). - 4.📱 Responsive design means a page ___. (a) fits every screen (b) has no pictures (c) never changes (d) is only for laptops
-
5.🖌️ Where does the text sit on its line?
p {
background-color: black;
text-align: left;
font-size: 32px;
color: purple;
} (a) on the left (b) in the middle (c) on the right -
6.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 26px;
}
} - 7.📱 Which tag helps phones show a page at the right size? (a) the viewport meta tag (b) the br tag (c) the title tag (d) the hr tag
-
8.⚖️ What colour is the text of this element?
<h1 class="menu" id="main">Hi</h1>
CSS:
.menu { color: orange; }
.menu { color: yellow; } (a) orange (b) purple (c) yellow (d) blue - 9.True or false: margin is the text or picture. (a) False (b) True
- 10.True or false: .menu is an element selector. (a) True (b) False
- 11.Which of these does HTML do? (a) makes a link (b) lays out the page (c) counts down a timer (d) adds space around boxes
- 12.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) exactly 1000px (c) 600px or narrower (d) turned off
- 13.🔍 Which is the odd one out? (a) reacts to a button click (b) changes the page live (c) shows a pop-up message (d) makes headings and lists
-
14.⚖️ What colour is the text of this element?
<h1 class="note" id="logo">Hi</h1>
CSS:
#logo { color: orange; }
h1 { color: purple; } (a) green (b) black (c) orange (d) purple -
15.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 32px;
}
} - 16.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 6 (b) 2 (c) 3 (d) 4
- 17.🧩 Which language puts a picture on a page? (a) CSS (b) HTML (c) JavaScript
-
18.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-weight: bold;
} -
19.⚖️ What colour is the text of this element?
<p class="menu" id="main">Hi</p>
CSS:
p { color: white; }
#main { color: green; } (a) white (b) blue (c) purple (d) green -
20.⚖️ What colour is the text of this element?
<h1 class="star" id="top">Hi</h1>
CSS:
.star { color: green; }
.star { color: black; } (a) black (b) green (c) yellow (d) white -
21.⚖️ What colour is the text of this element?
<h1 class="big" id="end">Hi</h1>
CSS:
.big { color: black; }
.big { color: blue; } (a) purple (b) red (c) blue (d) black -
22.✍️ Which property is set to 300px in this rule?
p {
width: 300px;
text-align: center;
font-weight: bold;
} (a) color (b) font-style (c) 300px (d) width -
23.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 24px;
}
} - 24.🖌️ Which CSS property picks the font style? (a) font-family (b) background-color (c) font-weight (d) color
- 25.🎯 Which element does the selector #hero style? (a) <div class="hero"> (b) <div id="hero"> (c) <div id="top"> (d) <span class="big">
-
26.⚖️ What colour is the text of this element?
<p class="note" id="top">Hi</p>
CSS:
p { color: purple; }
p { color: yellow; } (a) orange (b) yellow (c) purple (d) white - 27.🌈 In #230000 the red part is the hex number 23. What is it as a normal number?
-
28.✍️ How many declarations (property: value pairs) are in this rule?
li {
font-style: italic;
border: 2px solid;
text-align: center;
font-weight: bold;
} - 29.🌈 Which hex code is black? (a) #00ff00 (b) #000000 (c) #00ffff (d) #0000ff
- 30.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
- 31.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the first one (c) the shorter one (d) the later one
- 32.📦 In the box model, which part is space outside the border? (a) border (b) padding (c) margin (d) content
- 33.🎯 What kind of selector is li? (a) an id selector (b) a class selector (c) an element selector
- 34.True or false: margin is the gap round content. (a) True (b) False
-
35.✍️ What value is given to font-weight in this rule?
li {
font-weight: bold;
text-align: center;
padding: 8px;
background-color: yellow;
} (a) 2px solid (b) 300px (c) bold (d) font-weight - 36.🎯 Can many elements share the same class? (a) No (b) Yes
- 37.🌈 Which colour is #0000ff? (a) blue (b) red (c) magenta (d) bright green
-
38.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 280px;
padding: 25px;
border: 3px solid black;
margin: 20px;
} -
39.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 300px;
justify-content: center;
}
Inside are 3 boxes, each 60px wide (no margins). - 40.What does font-weight do? (a) centres a heading (b) picks the font style (c) makes the text bold (d) makes letters bigger
Answer key
- 70
- h1
- 10
- fits every screen
- on the left
- 20
- the viewport meta tag
- yellow
- False
- False
- makes a link
- 600px or narrower
- makes headings and lists
- orange
- 24
- 3
- HTML
- 1
- green
- black
- blue
- width
- 16
- font-family
- <div id="hero">
- yellow
- 35
- 4
- #000000
- an id selector
- the later one
- margin
- an element selector
- False
- bold
- Yes
- blue
- 336
- 60
- makes the text bold
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids