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: 110px;
padding: 5px;
border: 2px solid black;
margin: 20px;
} - 2.🎯 Which element does the selector div style? (a) <p class="menu"> (b) <div class="menu"> (c) <span> (d) <h1 id="top">
- 3.🔍 Which is the odd one out? (a) counts down a timer (b) shows a pop-up message (c) makes headings and lists (d) reacts to a button click
- 4.🔍 Which is the odd one out? (a) reacts to a button click (b) changes the text size (c) sets colours and fonts (d) rounds box corners
-
5.⚖️ What colour is the text of this element?
<p class="big" id="main">Hi</p>
CSS:
#main { color: purple; }
p { color: blue; } (a) white (b) blue (c) yellow (d) purple - 6.🎯 Which element does the selector h1 style? (a) <h1 class="box"> (b) <div id="end"> (c) <h2> (d) <li class="box">
-
7.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 320px;
justify-content: center;
}
Inside are 2 boxes, each 80px wide (no margins). - 8.🌈 Which colour is #000000? (a) red (b) yellow (c) black (d) blue
- 9.What does justify-content: space-between do? (a) puts boxes in the middle (b) packs boxes at the start (c) equal gaps, none at ends (d) packs boxes at the end
-
10.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 320px;
justify-content: flex-start;
}
Inside are 3 boxes, each 100px wide (no margins). - 11.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
- 12.🌈 Which hex code is white? (a) #ffff00 (b) #00ff00 (c) #ff0000 (d) #ffffff
-
13.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 100px;
padding: 30px;
border: 1px solid black;
margin: 15px;
} - 14.🖌️ Which CSS property centres a heading? (a) color (b) font-family (c) text-align (d) font-weight
-
15.⚖️ What colour is the text of this element?
<h2 class="menu" id="intro">Hi</h2>
CSS:
h2 { color: red; }
#intro { color: purple; } (a) yellow (b) red (c) purple (d) orange -
16.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 14px;
}
} - 17.🧩 Which language rounds box corners? (a) JavaScript (b) HTML (c) CSS
- 18.True or false: padding is space outside the border. (a) False (b) True
- 19.🎨 A CSS file usually ends with which extension? (a) .png (b) .html (c) .css (d) .js
-
20.✍️ What is the selector in this CSS rule?
.note {
padding: 8px;
font-style: italic;
font-size: 20px;
} (a) padding (b) italic (c) #top (d) .note -
21.✍️ What is the selector in this CSS rule?
.box {
background-color: yellow;
padding: 8px;
} (a) background-color (b) 8px (c) h2 (d) .box - 22.🎯 How many elements on a page should have the same id? (a) 5 (b) 2 (c) any number (d) 1
-
23.✍️ Which property is set to italic in this rule?
h1 {
font-style: italic;
border: 2px solid;
} (a) font-size (b) font-style (c) italic (d) color - 24.🌈 Which colour is #00ff00? (a) cyan (b) bright green (c) white (d) yellow
- 25.True or false: .menu is an id selector. (a) True (b) False
-
26.✍️ Which property is set to red in this rule?
h2 {
color: red;
padding: 8px;
background-color: yellow;
} (a) font-size (b) red (c) text-align (d) color -
27.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 10px;
}
} - 28.What does justify-content: flex-end do? (a) puts boxes in the middle (b) packs boxes at the end (c) packs boxes at the start (d) equal gaps, none at ends
-
29.🖌️ How big is the text, in px?
h1 {
text-align: center;
background-color: green;
font-size: 40px;
color: red;
} -
30.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 240px;
justify-content: center;
}
Inside are 2 boxes, each 100px wide (no margins). - 31.True or false: JavaScript makes a link. (a) True (b) False
- 32.📦 In the box model, which part is the gap to other boxes? (a) padding (b) margin (c) content (d) border
- 33.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
-
34.🎯 Which CSS selector matches this element?
<p class="star" id="main">Hello</p> (a) #star (b) .main (c) p (d) #logo - 35.🎨 One CSS file can style how many pages? (a) only one image (b) many pages (c) no pages (d) only one word
- 36.🌈 Which hex code is cyan? (a) #ff0000 (b) #00ffff (c) #ffffff (d) #ffff00
- 37.True or false: padding is the line round the box. (a) False (b) True
-
38.🖌️ What colour is behind the letters?
h2 {
font-size: 12px;
text-align: right;
background-color: purple;
color: white;
} (a) white (b) blue (c) purple - 39.What does justify-content: center do? (a) packs boxes at the start (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the end
- 40.True or false: the border is a solid or dotted edge. (a) True (b) False
Answer key
- 124
- <div class="menu">
- makes headings and lists
- reacts to a button click
- purple
- <h1 class="box">
- 80
- black
- equal gaps, none at ends
- 20
- an id selector
- #ffffff
- 162
- text-align
- purple
- 12
- CSS
- False
- .css
- .note
- .box
- 1
- font-style
- bright green
- False
- color
- 10
- packs boxes at the end
- 40
- 20
- False
- margin
- an element selector
- p
- many pages
- #00ffff
- False
- purple
- puts boxes in the middle
- True
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids