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.True or false: the border is space outside the border. (a) True (b) False
-
2.🎯 Which CSS selector matches this element?
<h2 class="big" id="main">Hello</h2> (a) .red (b) h2 (c) .main (d) #big -
3.⚖️ What colour is the text of this element?
<h2 class="big" id="logo">Hi</h2>
CSS:
h2 { color: green; }
#logo { color: yellow; } (a) purple (b) green (c) yellow (d) red - 4.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 3 (b) 4 (c) 6 (d) 2
- 5.🎯 What kind of selector is .big? (a) an element selector (b) a class selector (c) an id selector
- 6.💪 Which justify-content value equal gaps, none at ends? (a) center (b) space-between (c) flex-end (d) flex-start
- 7.🌈 Which hex code is yellow? (a) #ff00ff (b) #ffffff (c) #ffff00 (d) #00ffff
- 8.True or false: the content is space inside the border. (a) False (b) True
- 9.🔍 Which is the odd one out? (a) shows a pop-up message (b) makes a form box (c) changes the page live (d) counts down a timer
-
10.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 200px;
padding: 30px;
border: 2px solid black;
margin: 10px;
} -
11.🎯 Which CSS selector matches this element?
<span class="note" id="main">Hello</span> (a) .note (b) .big (c) p (d) .main -
12.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 30px;
}
} - 13.What does font-family do? (a) centres a heading (b) sets the letter colour (c) colours behind the text (d) picks the font style
- 14.✍️ In color: blue; which part is the property? (a) blue (b) ; (c) : (d) color
- 15.🎯 What kind of selector is #end? (a) a class selector (b) an element selector (c) an id selector
- 16.What does text-align do? (a) sets the letter colour (b) colours behind the text (c) makes the text bold (d) centres a heading
- 17.🎯 Which element does the selector .box style? (a) <li class="star"> (b) <li class="box"> (c) <li id="box"> (d) <div class="menu">
- 18.✍️ CSS declarations go inside which brackets? (a) ( ) (b) < > (c) [ ] (d) { }
-
19.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 270px;
justify-content: flex-end;
}
Inside are 4 boxes, each 50px wide (no margins). - 20.🖌️ Which CSS property makes the text bold? (a) font-weight (b) background-color (c) color (d) font-size
- 21.💪 Which flexbox property turns on flexbox? (a) gap (b) justify-content (c) display: flex (d) align-items
- 22.🎯 What kind of selector is .card? (a) an id selector (b) an element selector (c) a class selector
- 23.✍️ How does a CSS comment start? (a) /* (b) // (c) <!-- (d) #
- 24.🔍 Which is the odd one out? (a) checks a quiz answer (b) makes headings and lists (c) puts a picture on a page (d) makes a form box
- 25.📦 In the box model, which part is a solid or dotted edge? (a) padding (b) border (c) margin (d) content
-
26.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 180px;
justify-content: flex-start;
}
Inside are 4 boxes, each 40px wide (no margins). -
27.🎯 Which CSS selector matches this element?
<div class="star" id="hero">Hello</div> (a) .hero (b) #top (c) #hero (d) #star - 28.True or false: CSS adds space around boxes. (a) True (b) False
- 29.✍️ In color: blue; which part is the value? (a) ; (b) blue (c) : (d) color
- 30.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
-
31.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 190px;
padding: 30px;
border: 1px solid black;
margin: 15px;
} - 32.Which of these is margin? (a) the gap to other boxes (b) space inside the border (c) the gap round content (d) a solid or dotted edge
- 33.🎯 Which element does the selector #logo style? (a) <h1 class="logo"> (b) <h1 id="logo"> (c) <h1 id="end"> (d) <h2 class="menu">
-
34.⚖️ What colour is the text of this element?
<h2 class="big" id="top">Hi</h2>
CSS:
#top { color: yellow; }
.big { color: purple; }
h2 { color: red; } (a) green (b) purple (c) red (d) yellow -
35.✍️ What is the selector in this CSS rule?
li {
font-style: italic;
color: red;
padding: 8px;
} (a) li (b) body (c) red (d) font-style -
36.✍️ What is the selector in this CSS rule?
#top {
border: 2px solid;
padding: 8px;
} (a) 8px (b) border (c) li (d) #top -
37.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 26px;
}
} -
38.✍️ What is the selector in this CSS rule?
#top {
border: 2px solid;
padding: 8px;
text-align: center;
} (a) li (b) #top (c) 8px (d) border - 39.Which of these does HTML do? (a) lays out the page (b) gives the page structure (c) checks a quiz answer (d) reacts to a button click
-
40.⚖️ What colour is the text of this element?
<h2 class="star" id="hero">Hi</h2>
CSS:
#hero { color: black; }
#hero { color: orange; } (a) red (b) orange (c) green (d) black
Answer key
- False
- h2
- yellow
- 3
- a class selector
- space-between
- #ffff00
- False
- makes a form box
- 284
- .note
- 30
- picks the font style
- color
- an id selector
- centres a heading
- <li class="box">
- { }
- 70
- font-weight
- display: flex
- a class selector
- /*
- checks a quiz answer
- border
- 20
- #hero
- True
- blue
- an id selector
- 252
- the gap to other boxes
- <h1 id="logo">
- yellow
- li
- #top
- 26
- #top
- gives the page structure
- orange
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids