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.⚖️ What colour is the text of this element?
<h1 class="note" id="top">Hi</h1>
CSS:
h1 { color: white; }
.note { color: yellow; } (a) yellow (b) white (c) red (d) green - 2.True or false: padding is the gap round content. (a) True (b) False
- 3.🌈 Which colour of light is strongest in rgb(86, 31, 238)? (a) red (b) blue (c) green
- 4.💪 Which flexbox property sets space between boxes? (a) align-items (b) display: flex (c) gap (d) justify-content
-
5.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 280px;
justify-content: flex-start;
}
Inside are 2 boxes, each 100px wide (no margins). - 6.What does justify-content: space-between do? (a) puts boxes in the middle (b) packs boxes at the start (c) equal gaps, none at ends (d) packs boxes at the end
-
7.🖌️ What colour are the letters?
h2 {
text-align: center;
background-color: purple;
font-size: 20px;
color: black;
} (a) black (b) blue (c) purple - 8.🔍 Which is the odd one out? (a) sets colours and fonts (b) lays out the page (c) makes a form box (d) rounds box corners
- 9.🔍 Which is the odd one out? (a) counts down a timer (b) reacts to a button click (c) checks a quiz answer (d) makes headings and lists
- 10.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
-
11.⚖️ What colour is the text of this element?
<h1 class="star" id="end">Hi</h1>
CSS:
h1 { color: yellow; }
.star { color: white; } (a) orange (b) white (c) blue (d) yellow - 12.✍️ Which sign goes between a property and its value? (a) ; (b) = (c) - (d) :
- 13.📱 Which tag helps phones show a page at the right size? (a) the viewport meta tag (b) the br tag (c) the hr tag (d) the title tag
- 14.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 6 (b) 3 (c) 4 (d) 2
- 15.🧩 Which language shows a pop-up message? (a) JavaScript (b) HTML (c) CSS
- 16.🎯 How many elements on a page should have the same id? (a) any number (b) 1 (c) 2 (d) 5
- 17.✍️ How does a CSS comment start? (a) // (b) # (c) /* (d) <!--
- 18.🧩 Which language makes a form box? (a) HTML (b) JavaScript (c) CSS
- 19.🌈 Which colour is #0000ff? (a) blue (b) yellow (c) magenta (d) black
-
20.⚖️ What colour is the text of this element?
<h2 class="red" id="main">Hi</h2>
CSS:
.red { color: blue; }
.red { color: black; } (a) yellow (b) black (c) blue (d) red -
21.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 20px;
}
} (a) Yes (b) No - 22.📱 What does a media query check? (a) the screen width (b) the battery level (c) the page title (d) the time of day
- 23.🌈 Which hex code is cyan? (a) #ffff00 (b) #ffffff (c) #00ff00 (d) #00ffff
- 24.✍️ In color: blue; which part is the property? (a) blue (b) : (c) color (d) ;
-
25.🖌️ How big is the text, in px?
h2 {
background-color: yellow;
font-size: 36px;
text-align: center;
color: black;
} - 26.💪 Which flexbox property turns on flexbox? (a) display: flex (b) gap (c) flex-direction (d) align-items
- 27.🌈 What is the biggest number one colour can have in rgb()? (a) 255 (b) 99 (c) 100 (d) 1000
- 28.🎨 Which attribute adds CSS inside one tag? (a) href (b) alt (c) style (d) src
-
29.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 14px;
}
} - 30.📦 In the box model, which part is the text or picture? (a) padding (b) margin (c) content (d) border
- 31.🌈 Which colour is #000000? (a) cyan (b) black (c) blue (d) white
-
32.✍️ What value is given to padding in this rule?
body {
font-weight: bold;
padding: 8px;
} (a) 2px solid (b) bold (c) 8px (d) padding - 33.🖌️ Which CSS property colours behind the text? (a) font-weight (b) text-align (c) font-family (d) background-color
- 34.🎯 Can many elements share the same class? (a) No (b) Yes
- 35.🌈 In #00007c the blue part is the hex number 7c. What is it as a normal number?
- 36.What does font-family do? (a) picks the font style (b) sets the letter colour (c) centres a heading (d) makes letters bigger
- 37.What does background-color do? (a) centres a heading (b) colours behind the text (c) sets the letter colour (d) makes letters bigger
- 38.True or false: HTML adds space around boxes. (a) False (b) True
- 39.🌈 Which hex code is bright green? (a) #ff00ff (b) #0000ff (c) #00ff00 (d) #ffffff
- 40.🧩 Which language reacts to a button click? (a) CSS (b) JavaScript (c) HTML
Answer key
- yellow
- True
- blue
- gap
- 80
- equal gaps, none at ends
- black
- makes a form box
- makes headings and lists
- an element selector
- white
- :
- the viewport meta tag
- 3
- JavaScript
- 1
- /*
- HTML
- blue
- black
- Yes
- the screen width
- #00ffff
- color
- 36
- display: flex
- 255
- style
- 16
- content
- black
- 8px
- background-color
- Yes
- 124
- picks the font style
- colours behind the text
- False
- #00ff00
- JavaScript
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids