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 flexbox property sets space between boxes? (a) justify-content (b) gap (c) align-items (d) flex-direction
- 2.🎯 Which element does the selector #top style? (a) <h1 class="top"> (b) <h2 class="note"> (c) <h1 id="top"> (d) <h1 id="intro">
- 3.True or false: .star is a class selector. (a) False (b) True
- 4.🔍 Which is the odd one out? (a) adds space around boxes (b) reacts to a button click (c) checks a quiz answer (d) changes the page live
- 5.🎯 Which element does the selector .menu style? (a) <li class="big"> (b) <h2 id="menu"> (c) <h2 class="menu"> (d) <h2 class="note">
- 6.✍️ In color: blue; which part is the value? (a) : (b) blue (c) color (d) ;
-
7.✍️ What value is given to color in this rule?
.note {
margin: 10px;
color: red;
} (a) center (b) red (c) 20px (d) color -
8.🎯 Which CSS selector matches this element?
<p class="red" id="intro">Hello</p> (a) .intro (b) #red (c) #intro (d) .box -
9.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 160px;
justify-content: flex-end;
}
Inside are 2 boxes, each 60px wide (no margins). -
10.✍️ Which property is set to 8px in this rule?
#top {
font-weight: bold;
padding: 8px;
width: 300px;
font-size: 20px;
} (a) font-weight (b) border (c) 8px (d) padding - 11.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the br tag (c) the hr tag (d) the viewport meta tag
- 12.🌈 Which colour is rgb(255, 0, 0)? (a) magenta (b) red (c) black (d) cyan
- 13.✍️ How does a CSS comment start? (a) // (b) # (c) /* (d) <!--
-
14.🎯 Which CSS selector matches this element?
<h1 class="note" id="end">Hello</h1> (a) h2 (b) h1 (c) #note (d) #hero -
15.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 14px;
}
} (a) Yes (b) No - 16.True or false: JavaScript checks a quiz answer. (a) False (b) True
- 17.📦 In the box model, which part is the line round the box? (a) margin (b) padding (c) border (d) content
-
18.🎯 Which CSS selector matches this element?
<li class="star" id="intro">Hello</li> (a) .intro (b) div (c) #intro (d) #star - 19.True or false: .big is an element selector. (a) True (b) False
- 20.🖌️ Which CSS property centres a heading? (a) background-color (b) font-weight (c) text-align (d) font-size
- 21.✍️ CSS declarations go inside which brackets? (a) < > (b) ( ) (c) [ ] (d) { }
-
22.🖌️ What colour are the letters?
h1 {
color: white;
text-align: center;
font-size: 40px;
background-color: red;
} (a) purple (b) white (c) red - 23.Which of these does CSS do? (a) adds space around boxes (b) counts down a timer (c) gives the page structure (d) changes the page live
- 24.True or false: JavaScript rounds box corners. (a) False (b) True
- 25.What does justify-content: space-between 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
-
26.✍️ How many declarations (property: value pairs) are in this rule?
li {
width: 300px;
font-size: 20px;
margin: 10px;
} - 27.True or false: margin is space outside the border. (a) False (b) True
- 28.🖌️ Which CSS property makes letters bigger? (a) font-size (b) color (c) font-family (d) text-align
- 29.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
- 30.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
-
31.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 16px;
}
} - 32.🌈 Which hex code is black? (a) #000000 (b) #ff00ff (c) #ffff00 (d) #ffffff
- 33.🧩 Which language rounds box corners? (a) JavaScript (b) HTML (c) CSS
-
34.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 20px;
}
} -
35.⚖️ What colour is the text of this element?
<h2 class="star" id="top">Hi</h2>
CSS:
.star { color: orange; }
h2 { color: black; } (a) purple (b) orange (c) black (d) yellow - 36.🌈 Which colour of light is strongest in rgb(159, 129, 39)? (a) red (b) blue (c) green
- 37.🎯 Which element does the selector .star style? (a) <p id="star"> (b) <p class="menu"> (c) <h1 class="note"> (d) <p class="star">
- 38.🌈 Hex digits go 0 to 9, then A to which letter? (a) Z (b) F (c) J (d) G
- 39.🎯 What kind of selector is .note? (a) an id selector (b) an element selector (c) a class selector
-
40.🖌️ Where does the text sit on its line?
p {
text-align: right;
font-size: 20px;
background-color: yellow;
color: black;
} (a) on the left (b) in the middle (c) on the right
Answer key
- gap
- <h1 id="top">
- True
- adds space around boxes
- <h2 class="menu">
- blue
- red
- #intro
- 40
- padding
- the viewport meta tag
- red
- /*
- h1
- No
- True
- border
- #intro
- False
- text-align
- { }
- white
- adds space around boxes
- False
- equal gaps, none at ends
- 3
- True
- font-size
- an id selector
- an element selector
- 16
- #000000
- CSS
- 20
- orange
- red
- <p class="star">
- F
- a class selector
- on the right
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids