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 colour is rgb(255, 0, 0)? (a) yellow (b) red (c) blue (d) white
- 2.🧩 Which language counts down a timer? (a) HTML (b) CSS (c) JavaScript
- 3.🎯 Which element does the selector .menu style? (a) <p class="big"> (b) <span class="note"> (c) <span class="menu"> (d) <span id="menu">
-
4.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 250px;
padding: 5px;
border: 3px solid black;
margin: 15px;
} - 5.🧩 Which language lays out the page? (a) CSS (b) JavaScript (c) HTML
- 6.True or false: the border is the line round the box. (a) False (b) True
- 7.🖌️ Which CSS property sets the letter colour? (a) background-color (b) text-align (c) color (d) font-weight
- 8.Which of these does CSS do? (a) shows a pop-up message (b) counts down a timer (c) adds space around boxes (d) makes headings and lists
- 9.🌈 Which colour of light is strongest in rgb(170, 81, 127)? (a) blue (b) red (c) green
- 10.🎯 Which sign starts a class selector? (a) # (b) @ (c) & (d) .
-
11.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 430px;
justify-content: flex-end;
}
Inside are 4 boxes, each 100px wide (no margins). -
12.✍️ Which property is set to 8px in this rule?
p {
padding: 8px;
width: 300px;
} (a) 8px (b) border (c) padding (d) font-weight -
13.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 8px;
}
} - 14.✍️ In color: blue; which part is the property? (a) : (b) ; (c) blue (d) color
-
15.⚖️ What colour is the text of this element?
<h2 class="red" id="hero">Hi</h2>
CSS:
h2 { color: black; }
h2 { color: red; } (a) black (b) purple (c) red (d) orange - 16.📦 In the box model, which part is space inside the border? (a) margin (b) padding (c) border (d) content
- 17.What does font-weight do? (a) makes letters bigger (b) picks the font style (c) makes the text bold (d) centres a heading
- 18.🎯 Which element does the selector p style? (a) <p class="menu"> (b) <li id="logo"> (c) <h1> (d) <h2 class="menu">
-
19.⚖️ What colour is the text of this element?
<h2 class="box" id="end">Hi</h2>
CSS:
#end { color: green; }
#end { color: red; } (a) orange (b) purple (c) red (d) green - 20.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the later one (c) the first one (d) the shorter one
-
21.🖌️ What colour are the letters?
h1 {
background-color: black;
text-align: left;
font-size: 20px;
color: blue;
} (a) green (b) black (c) blue - 22.🌈 Which colour is #0000ff? (a) white (b) red (c) magenta (d) blue
- 23.True or false: HTML reacts to a button click. (a) True (b) False
- 24.What does font-size do? (a) centres a heading (b) makes letters bigger (c) picks the font style (d) colours behind the text
-
25.⚖️ What colour is the text of this element?
<h2 class="note" id="logo">Hi</h2>
CSS:
h2 { color: red; }
h2 { color: black; } (a) black (b) purple (c) red (d) green -
26.✍️ Which property is set to 300px in this rule?
body {
width: 300px;
font-style: italic;
background-color: yellow;
} (a) font-style (b) color (c) width (d) 300px - 27.🎯 What kind of selector is h1? (a) an element selector (b) a class selector (c) an id selector
- 28.🎨 Which attribute adds CSS inside one tag? (a) src (b) alt (c) href (d) style
- 29.True or false: margin is the gap round content. (a) True (b) False
-
30.⚖️ What colour is the text of this element?
<p class="big" id="top">Hi</p>
CSS:
.big { color: black; }
#top { color: blue; }
p { color: green; } (a) black (b) green (c) purple (d) blue -
31.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 180px;
padding: 25px;
border: 4px solid black;
margin: 15px;
} - 32.📱 Which tag helps phones show a page at the right size? (a) the viewport meta tag (b) the hr tag (c) the title tag (d) the br tag
-
33.🖌️ How big is the text, in px?
li {
font-size: 28px;
background-color: blue;
text-align: right;
color: green;
} - 34.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
-
35.🎯 Which CSS selector matches this element?
<div class="box" id="intro">Hello</div> (a) .intro (b) span (c) #main (d) div -
36.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 20px;
}
} - 37.What does justify-content: flex-start do? (a) puts boxes in the middle (b) equal gaps, none at ends (c) packs boxes at the end (d) packs boxes at the start
-
38.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 4 boxes, each 40px wide (no margins). - 39.🎯 Can many elements share the same class? (a) Yes (b) No
-
40.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 28px;
}
}
Answer key
- red
- JavaScript
- <span class="menu">
- 296
- CSS
- True
- color
- adds space around boxes
- red
- .
- 30
- padding
- 8
- color
- red
- padding
- makes the text bold
- <p class="menu">
- red
- the later one
- blue
- blue
- False
- makes letters bigger
- black
- width
- an element selector
- style
- False
- blue
- 268
- the viewport meta tag
- 28
- an element selector
- div
- 12
- packs boxes at the start
- 50
- Yes
- 20
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids