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 is the odd one out? (a) counts down a timer (b) reacts to a button click (c) shows a pop-up message (d) makes headings and lists
- 2.🧩 Which language makes a link? (a) JavaScript (b) CSS (c) HTML
-
3.⚖️ What colour is the text of this element?
<h2 class="star" id="intro">Hi</h2>
CSS:
.star { color: blue; }
h2 { color: purple; } (a) purple (b) blue (c) red (d) black -
4.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 10px;
}
} -
5.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 50px;
padding: 30px;
border: 4px solid black;
margin: 5px;
} - 6.🌈 Which colour is rgb(255, 255, 255)? (a) yellow (b) red (c) white (d) cyan
- 7.🔍 Which is the odd one out? (a) shows a pop-up message (b) checks a quiz answer (c) sets colours and fonts (d) reacts to a button click
- 8.📱 Which tag helps phones show a page at the right size? (a) the viewport meta tag (b) the hr tag (c) the title tag (d) the br tag
-
9.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 600px) {
p {
font-size: 28px;
}
} -
10.✍️ What is the selector in this CSS rule?
p {
text-align: center;
color: red;
} (a) .note (b) text-align (c) p (d) red -
11.🎯 Which CSS selector matches this element?
<h1 class="menu" id="intro">Hello</h1> (a) h1 (b) #main (c) h2 (d) .intro -
12.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 480px) {
p {
font-size: 14px;
}
} (a) Yes (b) No -
13.✍️ What is the selector in this CSS rule?
.box {
width: 300px;
background-color: yellow;
color: red;
} (a) h2 (b) yellow (c) width (d) .box - 14.What does color do? (a) centres a heading (b) colours behind the text (c) picks the font style (d) sets the letter colour
-
15.✍️ What value is given to background-color in this rule?
.note {
background-color: yellow;
margin: 10px;
} (a) 10px (b) background-color (c) 8px (d) yellow -
16.💪 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). -
17.🖌️ How big is the text, in px?
h1 {
text-align: center;
color: yellow;
background-color: black;
font-size: 12px;
} -
18.✍️ How many declarations (property: value pairs) are in this rule?
body {
background-color: yellow;
border: 2px solid;
margin: 10px;
font-style: italic;
} -
19.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 260px;
padding: 5px;
border: 1px solid black;
margin: 5px;
} - 20.🖌️ Which CSS property sets the letter colour? (a) font-weight (b) text-align (c) color (d) font-family
- 21.✍️ Which sign goes between a property and its value? (a) ; (b) : (c) - (d) =
- 22.🎯 What kind of selector is #top? (a) an id selector (b) a class selector (c) an element selector
-
23.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 110px;
padding: 5px;
border: 2px solid black;
margin: 0px;
} - 24.🌈 In #db0000 the red part is the hex number db. What is it as a normal number?
- 25.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) 800px or narrower (c) 800px or wider (d) exactly 100px
-
26.✍️ Which property is set to red in this rule?
.note {
font-style: italic;
font-weight: bold;
color: red;
border: 2px solid;
} (a) text-align (b) font-size (c) red (d) color -
27.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 180px;
padding: 15px;
border: 4px solid black;
margin: 15px;
} - 28.🌈 In #001400 the green part is the hex number 14. What is it as a normal number?
- 29.Which of these is margin? (a) the gap round content (b) space outside the border (c) space inside the border (d) the line round the box
-
30.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 240px;
padding: 15px;
border: 1px solid black;
margin: 0px;
} - 31.🎯 Which sign starts an id selector? (a) @ (b) . (c) & (d) #
-
32.🖌️ What colour are the letters?
h2 {
font-size: 20px;
color: purple;
background-color: yellow;
text-align: center;
} (a) purple (b) white (c) yellow - 33.Which of these is the content? (a) a solid or dotted edge (b) space inside the border (c) the line round the box (d) the text or picture
-
34.✍️ Which property is set to red in this rule?
h2 {
color: red;
margin: 10px;
} (a) color (b) font-size (c) red (d) text-align -
35.✍️ What is the selector in this CSS rule?
body {
font-size: 20px;
margin: 10px;
text-align: center;
} (a) font-size (b) 10px (c) .box (d) body -
36.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 20px;
}
} - 37.🔍 Which is the odd one out? (a) reacts to a button click (b) checks a quiz answer (c) changes the page live (d) rounds box corners
- 38.📦 In the box model, which part is the text or picture? (a) margin (b) content (c) padding (d) border
- 39.✍️ In color: blue; which part is the value? (a) blue (b) ; (c) color (d) :
-
40.✍️ Which property is set to 8px in this rule?
h1 {
padding: 8px;
margin: 10px;
} (a) font-weight (b) 8px (c) border (d) padding
Answer key
- makes headings and lists
- HTML
- blue
- 12
- 118
- white
- sets colours and fonts
- the viewport meta tag
- 20
- p
- h1
- Yes
- .box
- sets the letter colour
- yellow
- 80
- 12
- 4
- 282
- color
- :
- an id selector
- 124
- 219
- 800px or wider
- color
- 248
- 20
- space outside the border
- 272
- #
- purple
- the text or picture
- color
- body
- 16
- rounds box corners
- content
- blue
- padding
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids