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: flex-start 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
-
2.⚖️ What colour is the text of this element?
<p class="big" id="end">Hi</p>
CSS:
p { color: blue; }
#end { color: white; }
.big { color: yellow; } (a) yellow (b) blue (c) red (d) white - 3.📦 In the box model, which part is space outside the border? (a) margin (b) content (c) padding (d) border
- 4.🔍 Which is the odd one out? (a) lays out the page (b) rounds box corners (c) changes the text size (d) makes headings and lists
-
5.🖌️ How big is the text, in px?
li {
background-color: white;
font-size: 24px;
text-align: left;
color: yellow;
} -
6.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 120px;
padding: 15px;
border: 1px solid black;
margin: 10px;
} -
7.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 220px;
justify-content: center;
}
Inside are 2 boxes, each 80px wide (no margins). -
8.⚖️ What colour is the text of this element?
<h1 class="note" id="intro">Hi</h1>
CSS:
#intro { color: orange; }
#intro { color: blue; } (a) yellow (b) blue (c) black (d) orange - 9.📱 What does a media query check? (a) the screen width (b) the battery level (c) the page title (d) the time of day
- 10.True or false: JavaScript shows a pop-up message. (a) True (b) False
- 11.🔍 Which is the odd one out? (a) changes the text size (b) sets colours and fonts (c) adds space around boxes (d) counts down a timer
- 12.🌈 Which colour is rgb(0, 255, 0)? (a) blue (b) red (c) cyan (d) bright green
- 13.⚖️ Which selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
-
14.🖌️ What colour are the letters?
h1 {
background-color: blue;
font-size: 36px;
color: purple;
text-align: center;
} (a) blue (b) purple (c) white -
15.✍️ How many declarations (property: value pairs) are in this rule?
#top {
padding: 8px;
font-weight: bold;
width: 300px;
} - 16.🎯 Which element does the selector div style? (a) <h1 id="logo"> (b) <span> (c) <p class="big"> (d) <div class="big">
- 17.🌈 Which colour of light is strongest in rgb(123, 131, 217)? (a) blue (b) red (c) green
-
18.✍️ Which property is set to 20px in this rule?
li {
font-size: 20px;
color: red;
background-color: yellow;
} (a) 20px (b) font-size (c) background-color (d) text-align - 19.True or false: the border is a solid or dotted edge. (a) True (b) False
- 20.True or false: HTML checks a quiz answer. (a) False (b) True
-
21.⚖️ What colour is the text of this element?
<p class="star" id="intro">Hi</p>
CSS:
p { color: black; }
p { color: red; } (a) black (b) blue (c) white (d) red - 22.🌈 Which colour is #ffffff? (a) bright green (b) red (c) magenta (d) white
-
23.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: flex-end;
}
Inside are 3 boxes, each 80px wide (no margins). - 24.True or false: .card is an id selector. (a) True (b) False
-
25.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 120px;
justify-content: flex-end;
}
Inside are 2 boxes, each 40px wide (no margins). -
26.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 160px;
padding: 5px;
border: 3px solid black;
margin: 0px;
} - 27.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the viewport meta tag (c) the br tag (d) the title tag
-
28.✍️ What value is given to width in this rule?
.box {
background-color: yellow;
width: 300px;
} (a) 300px (b) italic (c) width (d) red - 29.✍️ Which sign ends each CSS declaration? (a) ; (b) , (c) : (d) .
-
30.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 130px;
padding: 10px;
border: 2px solid black;
margin: 5px;
} -
31.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 80px;
padding: 20px;
border: 4px solid black;
margin: 15px;
} -
32.⚖️ What colour is the text of this element?
<h2 class="big" id="logo">Hi</h2>
CSS:
h2 { color: orange; }
#logo { color: red; }
.big { color: purple; } (a) red (b) blue (c) orange (d) purple -
33.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 190px;
padding: 15px;
border: 4px solid black;
margin: 15px;
} - 34.🌈 Which colour of light is strongest in rgb(118, 33, 206)? (a) blue (b) green (c) red
- 35.True or false: #hero is an element selector. (a) True (b) False
-
36.🎯 Which CSS selector matches this element?
<div class="box" id="top">Hello</div> (a) .box (b) #intro (c) span (d) .star - 37.True or false: HTML makes a form box. (a) True (b) False
-
38.🖌️ What colour are the letters?
h1 {
color: purple;
background-color: blue;
text-align: right;
font-size: 16px;
} (a) blue (b) white (c) purple - 39.🔍 Which is the odd one out? (a) reacts to a button click (b) checks a quiz answer (c) sets colours and fonts (d) changes the page live
- 40.True or false: #hero is a class selector. (a) True (b) False
Answer key
- packs boxes at the start
- white
- margin
- makes headings and lists
- 24
- 172
- 30
- blue
- the screen width
- True
- counts down a timer
- bright green
- an id selector
- purple
- 3
- <div class="big">
- blue
- font-size
- True
- False
- red
- white
- 20
- False
- 40
- 176
- the viewport meta tag
- 300px
- ;
- 164
- 158
- red
- 258
- blue
- False
- .box
- True
- purple
- sets colours and fonts
- False
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids