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 CSS property centres a heading? (a) font-weight (b) text-align (c) color (d) background-color
- 2.🎯 Which element does the selector .note style? (a) <p class="note"> (b) <h1 class="red"> (c) <p class="big"> (d) <p id="note">
- 3.Which of these does CSS do? (a) rounds box corners (b) makes a link (c) puts a picture on a page (d) counts down a timer
- 4.📱 What does a media query check? (a) the screen width (b) the time of day (c) the battery level (d) the page title
- 5.📦 In the box model, which part is the text or picture? (a) margin (b) padding (c) border (d) content
- 6.True or false: HTML shows a pop-up message. (a) True (b) False
- 7.True or false: .card is an id selector. (a) True (b) False
-
8.✍️ Which property is set to center in this rule?
h1 {
text-align: center;
border: 2px solid;
color: red;
} (a) center (b) background-color (c) text-align (d) margin - 9.✍️ CSS declarations go inside which brackets? (a) ( ) (b) { } (c) < > (d) [ ]
- 10.True or false: .star is a class selector. (a) False (b) True
- 11.🌈 Which colour is #0000ff? (a) black (b) yellow (c) red (d) blue
- 12.🎯 Which element does the selector #logo style? (a) <p class="logo"> (b) <p id="end"> (c) <h1 class="note"> (d) <p id="logo">
-
13.⚖️ What colour is the text of this element?
<h1 class="menu" id="hero">Hi</h1>
CSS:
#hero { color: black; }
#hero { color: blue; } (a) blue (b) orange (c) black (d) red -
14.🖌️ Where does the text sit on its line?
h1 {
background-color: yellow;
color: orange;
font-size: 28px;
text-align: left;
} (a) on the left (b) on the right (c) in the middle - 15.What does background-color do? (a) centres a heading (b) picks the font style (c) makes letters bigger (d) colours behind the text
-
16.⚖️ What colour is the text of this element?
<p class="big" id="end">Hi</p>
CSS:
.big { color: purple; }
#end { color: red; }
p { color: black; } (a) green (b) red (c) purple (d) black -
17.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
font-style: italic;
width: 300px;
text-align: center;
margin: 10px;
} - 18.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) blue (c) white (d) green
-
19.🖌️ Where does the text sit on its line?
p {
font-size: 28px;
text-align: left;
background-color: red;
color: black;
} (a) on the left (b) on the right (c) in the middle - 20.🎯 Which element does the selector h1 style? (a) <li class="menu"> (b) <h2> (c) <div id="top"> (d) <h1 class="menu">
-
21.⚖️ What colour is the text of this element?
<p class="note" id="top">Hi</p>
CSS:
.note { color: yellow; }
#top { color: blue; } (a) black (b) yellow (c) red (d) blue -
22.⚖️ What colour is the text of this element?
<h1 class="menu" id="logo">Hi</h1>
CSS:
#logo { color: black; }
h1 { color: yellow; } (a) yellow (b) red (c) black (d) white -
23.🎯 Which CSS selector matches this element?
<div class="box" id="hero">Hello</div> (a) #box (b) div (c) #top (d) .hero -
24.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 480px) {
p {
font-size: 14px;
}
} -
25.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 50px;
padding: 25px;
border: 2px solid black;
margin: 15px;
} -
26.✍️ How many declarations (property: value pairs) are in this rule?
body {
padding: 8px;
font-size: 20px;
} -
27.✍️ Which property is set to 2px solid in this rule?
p {
font-style: italic;
border: 2px solid;
margin: 10px;
font-weight: bold;
} (a) width (b) 2px solid (c) font-style (d) border - 28.🎯 Which element does the selector #end style? (a) <li class="big"> (b) <h2 id="end"> (c) <h2 id="hero"> (d) <h2 class="end">
- 29.🌈 Which hex code is blue? (a) #ffff00 (b) #ff0000 (c) #0000ff (d) #00ffff
-
30.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 170px;
padding: 15px;
border: 1px solid black;
margin: 5px;
} - 31.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the shorter one (c) the first one (d) neither
-
32.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 190px;
justify-content: flex-start;
}
Inside are 2 boxes, each 60px wide (no margins). -
33.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 150px;
padding: 30px;
border: 1px solid black;
margin: 20px;
} - 34.🖌️ Which CSS property makes the text bold? (a) font-family (b) font-size (c) color (d) font-weight
-
35.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 1024px) {
p {
font-size: 30px;
}
} (a) Yes (b) No - 36.💪 Which flexbox property spaces boxes along a row? (a) justify-content (b) display: flex (c) align-items (d) flex-direction
- 37.What does font-size do? (a) makes letters bigger (b) centres a heading (c) sets the letter colour (d) makes the text bold
- 38.🎯 Which sign starts a class selector? (a) # (b) @ (c) . (d) &
- 39.📱 min-width: 800px applies when the screen is ___. (a) exactly 100px (b) turned off (c) 800px or wider (d) 800px or narrower
- 40.🌈 Which hex code is yellow? (a) #ff00ff (b) #00ff00 (c) #ffff00 (d) #00ffff
Answer key
- text-align
- <p class="note">
- rounds box corners
- the screen width
- content
- False
- False
- text-align
- { }
- True
- blue
- <p id="logo">
- blue
- on the left
- colours behind the text
- red
- 4
- blue
- on the left
- <h1 class="menu">
- blue
- black
- div
- 16
- 134
- 2
- border
- <h2 id="end">
- #0000ff
- 202
- the later one
- 70
- 252
- font-weight
- Yes
- justify-content
- makes letters bigger
- .
- 800px or wider
- #ffff00
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids