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: 70px;
padding: 25px;
border: 5px solid black;
margin: 5px;
} -
2.⚖️ What colour is the text of this element?
<p class="box" id="top">Hi</p>
CSS:
p { color: red; }
.box { color: green; }
#top { color: blue; } (a) red (b) white (c) blue (d) green - 3.🌈 Which colour is rgb(255, 0, 0)? (a) white (b) blue (c) red (d) bright green
-
4.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 120px;
padding: 20px;
border: 5px solid black;
margin: 10px;
} - 5.🎨 Which tag connects an outside CSS file? (a) <img> (b) <a> (c) <css> (d) <link>
- 6.🎯 What kind of selector is .big? (a) an id selector (b) an element selector (c) a class selector
-
7.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 60px;
padding: 5px;
border: 3px solid black;
margin: 5px;
} - 8.🌈 In #0000cc the blue part is the hex number cc. What is it as a normal number?
- 9.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or narrower (c) turned off (d) 600px or wider
- 10.💪 Which justify-content value equal gaps, none at ends? (a) flex-end (b) center (c) flex-start (d) space-between
-
11.🎯 Which CSS selector matches this element?
<p class="big" id="top">Hello</p> (a) .red (b) p (c) #big (d) #intro - 12.🔍 Which is the odd one out? (a) reacts to a button click (b) checks a quiz answer (c) changes the page live (d) lays out the page
-
13.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} (a) Yes (b) No - 14.🌈 Which hex code is red? (a) #ff00ff (b) #ffffff (c) #00ff00 (d) #ff0000
- 15.True or false: #logo is a class selector. (a) False (b) True
- 16.🎨 One CSS file can style how many pages? (a) only one image (b) only one word (c) many pages (d) no pages
-
17.🎯 Which CSS selector matches this element?
<span class="note" id="top">Hello</span> (a) .big (b) p (c) #intro (d) #top - 18.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
- 19.✍️ In color: blue; which part is the property? (a) blue (b) color (c) ; (d) :
- 20.What does text-align do? (a) sets the letter colour (b) picks the font style (c) centres a heading (d) makes letters bigger
-
21.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 14px;
}
} - 22.🌈 Which colour of light is strongest in rgb(84, 231, 91)? (a) green (b) red (c) blue
- 23.🎯 Which element does the selector #end style? (a) <li class="end"> (b) <li id="end"> (c) <div class="star"> (d) <li id="hero">
-
24.🖌️ What colour are the letters?
p {
background-color: red;
font-size: 36px;
color: yellow;
text-align: center;
} (a) yellow (b) black (c) red - 25.Which of these is padding? (a) the gap to other boxes (b) the gap round content (c) the text or picture (d) a solid or dotted edge
-
26.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 200px;
padding: 30px;
border: 5px solid black;
margin: 15px;
} - 27.Which of these is the border? (a) the gap round content (b) space inside the border (c) a solid or dotted edge (d) the gap to other boxes
- 28.💪 Which flexbox property turns on flexbox? (a) justify-content (b) display: flex (c) align-items (d) flex-direction
- 29.🌈 Which colour is rgb(255, 0, 255)? (a) blue (b) white (c) magenta (d) red
-
30.⚖️ What colour is the text of this element?
<h1 class="red" id="main">Hi</h1>
CSS:
.red { color: purple; }
.red { color: blue; } (a) purple (b) red (c) blue (d) yellow - 31.📦 In the box model, which part is a solid or dotted edge? (a) border (b) content (c) margin (d) padding
-
32.🎯 Which CSS selector matches this element?
<p class="big" id="main">Hello</p> (a) .big (b) #big (c) .red (d) #logo -
33.✍️ What is the selector in this CSS rule?
h1 {
color: red;
font-style: italic;
font-weight: bold;
} (a) italic (b) color (c) p (d) h1 - 34.💪 Which justify-content value puts boxes in the middle? (a) center (b) flex-end (c) flex-start (d) space-between
- 35.Which of these is padding? (a) space inside the border (b) the text or picture (c) a solid or dotted edge (d) space outside the border
- 36.Which of these does JavaScript do? (a) makes a link (b) reacts to a button click (c) sets colours and fonts (d) adds space around boxes
- 37.📦 In the box model, which part is space inside the border? (a) border (b) content (c) margin (d) padding
- 38.What does justify-content: flex-end do? (a) packs boxes at the start (b) equal gaps, none at ends (c) packs boxes at the end (d) puts boxes in the middle
- 39.What does justify-content: space-between do? (a) packs boxes at the start (b) packs boxes at the end (c) puts boxes in the middle (d) equal gaps, none at ends
-
40.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 24px;
}
}
Answer key
- 130
- blue
- red
- 190
- <link>
- a class selector
- 86
- 204
- 600px or narrower
- space-between
- p
- lays out the page
- No
- #ff0000
- False
- many pages
- #top
- an element selector
- color
- centres a heading
- 14
- green
- <li id="end">
- yellow
- the gap round content
- 300
- a solid or dotted edge
- display: flex
- magenta
- blue
- border
- .big
- h1
- center
- space inside the border
- reacts to a button click
- padding
- packs boxes at the end
- equal gaps, none at ends
- 24
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids