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: margin is space outside the border. (a) False (b) True
- 2.💪 Which justify-content value packs boxes at the start? (a) space-between (b) center (c) flex-start (d) flex-end
-
3.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 2 boxes, each 100px wide (no margins). - 4.🔍 Which is the odd one out? (a) makes a form box (b) puts a picture on a page (c) checks a quiz answer (d) gives the page structure
-
5.⚖️ What colour is the text of this element?
<h1 class="box" id="intro">Hi</h1>
CSS:
h1 { color: red; }
.box { color: black; }
#intro { color: yellow; } (a) red (b) black (c) blue (d) yellow - 6.🧩 Which language changes the text size? (a) HTML (b) JavaScript (c) CSS
-
7.⚖️ What colour is the text of this element?
<p class="red" id="end">Hi</p>
CSS:
p { color: black; }
p { color: orange; } (a) black (b) green (c) blue (d) orange -
8.🖌️ What colour is behind the letters?
p {
text-align: left;
color: black;
font-size: 32px;
background-color: green;
} (a) black (b) orange (c) green - 9.Which of these does CSS do? (a) makes a form box (b) makes headings and lists (c) makes a link (d) lays out the page
- 10.📦 In the box model, which part is the gap round content? (a) border (b) content (c) padding (d) margin
- 11.📱 Responsive design means a page ___. (a) has no pictures (b) fits every screen (c) never changes (d) is only for laptops
- 12.🌈 Which colour is rgb(255, 255, 0)? (a) red (b) white (c) yellow (d) bright green
-
13.✍️ What is the selector in this CSS rule?
h2 {
padding: 8px;
width: 300px;
text-align: center;
border: 2px solid;
} (a) padding (b) h1 (c) 300px (d) h2 -
14.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 8px;
}
} -
15.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 16px;
}
} - 16.🎯 Which sign starts an id selector? (a) . (b) & (c) @ (d) #
- 17.💪 Which flexbox property lines boxes up across? (a) gap (b) justify-content (c) flex-direction (d) align-items
- 18.💪 Which flexbox property sets space between boxes? (a) flex-direction (b) justify-content (c) display: flex (d) gap
-
19.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 18px;
}
} - 20.🌈 Which colour of light is strongest in rgb(90, 229, 88)? (a) green (b) red (c) blue
-
21.✍️ Which property is set to bold in this rule?
.note {
font-weight: bold;
font-style: italic;
} (a) border (b) font-weight (c) width (d) bold -
22.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 20px;
}
} - 23.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the first one (c) neither (d) the shorter one
- 24.What does font-size do? (a) makes letters bigger (b) centres a heading (c) sets the letter colour (d) colours behind the text
-
25.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 768px) {
p {
font-size: 14px;
}
} (a) Yes (b) No -
26.✍️ Which property is set to yellow in this rule?
p {
background-color: yellow;
padding: 8px;
color: red;
} (a) yellow (b) background-color (c) padding (d) margin -
27.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 10px;
}
} (a) Yes (b) No -
28.✍️ What value is given to padding in this rule?
h2 {
padding: 8px;
font-style: italic;
border: 2px solid;
} (a) 8px (b) bold (c) padding (d) 2px solid -
29.🖌️ How big is the text, in px?
h1 {
color: white;
background-color: blue;
font-size: 36px;
text-align: right;
} - 30.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
- 31.🎯 Which sign starts a class selector? (a) . (b) & (c) @ (d) #
-
32.✍️ What value is given to padding in this rule?
#top {
padding: 8px;
width: 300px;
} (a) 2px solid (b) padding (c) bold (d) 8px -
33.🎯 Which CSS selector matches this element?
<div class="note" id="hero">Hello</div> (a) span (b) div (c) #note (d) #top - 34.True or false: JavaScript reacts to a button click. (a) False (b) True
- 35.🌈 In #rrggbb, which colour do the last two digits give? (a) white (b) red (c) blue (d) green
- 36.✍️ Which sign goes between a property and its value? (a) - (b) : (c) ; (d) =
- 37.🎯 Which element does the selector .star style? (a) <p class="star"> (b) <h1 class="note"> (c) <p class="menu"> (d) <p id="star">
- 38.📱 Which tag helps phones show a page at the right size? (a) the br tag (b) the title tag (c) the viewport meta tag (d) the hr tag
- 39.🌈 Hex digits go 0 to 9, then A to which letter? (a) F (b) Z (c) J (d) G
- 40.Which of these does CSS do? (a) counts down a timer (b) adds space around boxes (c) makes a form box (d) changes the page live
Answer key
- True
- flex-start
- 30
- checks a quiz answer
- yellow
- CSS
- orange
- green
- lays out the page
- padding
- fits every screen
- yellow
- h2
- 8
- 20
- #
- align-items
- gap
- 12
- green
- font-weight
- 12
- the later one
- makes letters bigger
- No
- background-color
- Yes
- 8px
- 36
- an element selector
- .
- 8px
- div
- True
- blue
- :
- <p class="star">
- the viewport meta tag
- F
- adds space around boxes
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids