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 of these does JavaScript do? (a) adds space around boxes (b) sets colours and fonts (c) counts down a timer (d) makes a link
- 2.True or false: JavaScript puts a picture on a page. (a) False (b) True
-
3.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} (a) No (b) Yes - 4.✍️ Which sign ends each CSS declaration? (a) : (b) ; (c) , (d) .
- 5.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) neither (c) the later one (d) the first one
- 6.🌈 Which colour is #00ffff? (a) white (b) cyan (c) black (d) bright green
-
7.🖌️ What colour are the letters?
h1 {
text-align: left;
background-color: white;
color: red;
font-size: 24px;
} (a) red (b) green (c) white - 8.What does justify-content: flex-end 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
- 9.🎯 Which element does the selector h1 style? (a) <li class="red"> (b) <div id="intro"> (c) <h2> (d) <h1 class="red">
- 10.🌈 Which colour is #ff0000? (a) blue (b) black (c) red (d) white
- 11.🖌️ Which CSS property colours behind the text? (a) background-color (b) font-weight (c) text-align (d) font-size
-
12.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 170px;
padding: 20px;
border: 2px solid black;
margin: 20px;
} -
13.✍️ What is the selector in this CSS rule?
.box {
width: 300px;
color: red;
border: 2px solid;
padding: 8px;
} (a) .box (b) red (c) h2 (d) width -
14.⚖️ What colour is the text of this element?
<p class="note" id="intro">Hi</p>
CSS:
p { color: purple; }
p { color: white; } (a) purple (b) white (c) black (d) green - 15.🔍 Which is the odd one out? (a) reacts to a button click (b) changes the page live (c) checks a quiz answer (d) makes a link
- 16.📦 In the box model, which part is space inside the border? (a) content (b) padding (c) border (d) margin
- 17.What does background-color do? (a) makes letters bigger (b) colours behind the text (c) picks the font style (d) sets the letter colour
- 18.🎯 Which element does the selector .star style? (a) <p class="menu"> (b) <h1 class="note"> (c) <p class="star"> (d) <p id="star">
-
19.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 110px;
padding: 10px;
border: 3px solid black;
margin: 10px;
} - 20.🎨 One CSS file can style how many pages? (a) only one word (b) no pages (c) many pages (d) only one image
- 21.🌈 Which hex code is red? (a) #000000 (b) #00ffff (c) #ff0000 (d) #00ff00
- 22.🌈 Which hex code is magenta? (a) #ffffff (b) #ff00ff (c) #00ff00 (d) #ff0000
- 23.🎯 What kind of selector is li? (a) a class selector (b) an id selector (c) an element selector
- 24.True or false: CSS reacts to a button click. (a) True (b) False
- 25.What does font-size do? (a) picks the font style (b) colours behind the text (c) makes letters bigger (d) sets the letter colour
-
26.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 18px;
}
} (a) No (b) Yes -
27.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 400px;
justify-content: center;
}
Inside are 3 boxes, each 100px wide (no margins). -
28.🖌️ Where does the text sit on its line?
h2 {
text-align: left;
color: purple;
font-size: 40px;
background-color: red;
} (a) on the right (b) in the middle (c) on the left -
29.⚖️ What colour is the text of this element?
<h1 class="star" id="top">Hi</h1>
CSS:
#top { color: green; }
#top { color: purple; } (a) green (b) red (c) purple (d) blue -
30.✍️ What value is given to padding in this rule?
p {
color: red;
padding: 8px;
} (a) 8px (b) bold (c) padding (d) 2px solid -
31.✍️ What value is given to background-color in this rule?
h1 {
font-weight: bold;
background-color: yellow;
} (a) background-color (b) 10px (c) 8px (d) yellow - 32.📱 min-width: 800px applies when the screen is ___. (a) exactly 100px (b) turned off (c) 800px or wider (d) 800px or narrower
-
33.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 110px;
padding: 25px;
border: 4px solid black;
margin: 0px;
} - 34.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) blue (c) green (d) white
- 35.🎯 Which sign starts an id selector? (a) # (b) @ (c) . (d) &
-
36.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 14px;
}
} (a) Yes (b) No -
37.🖌️ What colour is behind the letters?
p {
text-align: left;
background-color: yellow;
font-size: 36px;
color: green;
} (a) black (b) yellow (c) green -
38.🎯 Which CSS selector matches this element?
<div class="menu" id="top">Hello</div> (a) .note (b) div (c) #intro (d) span -
39.🖌️ What colour is behind the letters?
h2 {
background-color: green;
text-align: left;
color: black;
font-size: 40px;
} (a) white (b) black (c) green -
40.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 20px;
}
}
Answer key
- counts down a timer
- False
- Yes
- ;
- the later one
- cyan
- red
- packs boxes at the end
- <h1 class="red">
- red
- background-color
- 254
- .box
- white
- makes a link
- padding
- colours behind the text
- <p class="star">
- 156
- many pages
- #ff0000
- #ff00ff
- an element selector
- False
- makes letters bigger
- Yes
- 50
- on the left
- purple
- 8px
- yellow
- 800px or wider
- 168
- blue
- #
- No
- yellow
- div
- green
- 16
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids