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="star" id="end">Hi</h1>
CSS:
#end { color: yellow; }
#end { color: orange; } (a) orange (b) black (c) green (d) yellow -
2.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 340px;
justify-content: center;
}
Inside are 4 boxes, each 80px wide (no margins). - 3.True or false: #main is a class selector. (a) False (b) True
-
4.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 280px;
justify-content: space-between;
}
Inside are 4 boxes, each 40px wide (no margins). -
5.🎯 Which CSS selector matches this element?
<div class="note" id="intro">Hello</div> (a) #note (b) span (c) div (d) #main -
6.⚖️ What colour is the text of this element?
<p class="red" id="logo">Hi</p>
CSS:
.red { color: red; }
.red { color: blue; } (a) blue (b) white (c) red (d) black - 7.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) exactly 100px (c) turned off (d) 800px or wider
- 8.🎯 Can many elements share the same class? (a) No (b) Yes
- 9.🌈 Which hex code is white? (a) #ffff00 (b) #0000ff (c) #ffffff (d) #ff0000
- 10.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the title tag (c) the viewport meta tag (d) the br tag
- 11.💪 Which flexbox property picks row or column? (a) justify-content (b) flex-direction (c) gap (d) display: flex
- 12.🌈 Which colour is #ff00ff? (a) magenta (b) bright green (c) blue (d) cyan
- 13.🌈 Which colour is #00ff00? (a) blue (b) cyan (c) bright green (d) magenta
-
14.✍️ Which property is set to 8px in this rule?
p {
padding: 8px;
border: 2px solid;
} (a) 8px (b) font-weight (c) padding (d) border -
15.⚖️ What colour is the text of this element?
<h1 class="big" id="hero">Hi</h1>
CSS:
#hero { color: black; }
.big { color: yellow; } (a) red (b) white (c) yellow (d) black -
16.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 600px) {
p {
font-size: 28px;
}
} (a) Yes (b) No -
17.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 380px;
justify-content: space-between;
}
Inside are 4 boxes, each 80px wide (no margins). -
18.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 300px;
justify-content: flex-start;
}
Inside are 3 boxes, each 80px wide (no margins). - 19.True or false: .star is a class selector. (a) False (b) True
- 20.True or false: .card is an element selector. (a) True (b) False
- 21.🧩 Which language shows a pop-up message? (a) CSS (b) JavaScript (c) HTML
- 22.✍️ Which sign goes between a property and its value? (a) = (b) - (c) : (d) ;
- 23.🌈 Which hex code is blue? (a) #000000 (b) #ffff00 (c) #ffffff (d) #0000ff
-
24.⚖️ What colour is the text of this element?
<h2 class="note" id="hero">Hi</h2>
CSS:
h2 { color: white; }
h2 { color: yellow; } (a) red (b) yellow (c) green (d) white -
25.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 240px;
padding: 20px;
border: 5px solid black;
margin: 20px;
} - 26.🧩 Which language changes the text size? (a) CSS (b) HTML (c) JavaScript
- 27.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or narrower (c) turned off (d) 600px or wider
-
28.🖌️ What colour is behind the letters?
h2 {
text-align: left;
background-color: red;
color: white;
font-size: 32px;
} (a) white (b) black (c) red - 29.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) justify-content (c) display: flex (d) gap
- 30.🔍 Which is the odd one out? (a) reacts to a button click (b) makes headings and lists (c) changes the page live (d) counts down a timer
- 31.Which of these does CSS do? (a) sets colours and fonts (b) counts down a timer (c) changes the page live (d) makes headings and lists
- 32.📱 Responsive design means a page ___. (a) fits every screen (b) has no pictures (c) never changes (d) is only for laptops
- 33.Which of these does CSS do? (a) reacts to a button click (b) rounds box corners (c) makes a link (d) shows a pop-up message
-
34.✍️ How many declarations (property: value pairs) are in this rule?
.note {
border: 2px solid;
background-color: yellow;
font-style: italic;
} - 35.True or false: h1 is an element selector. (a) False (b) True
- 36.True or false: the border is a solid or dotted edge. (a) False (b) True
-
37.✍️ What is the selector in this CSS rule?
h2 {
text-align: center;
padding: 8px;
margin: 10px;
font-style: italic;
} (a) h2 (b) 8px (c) h1 (d) text-align -
38.✍️ What is the selector in this CSS rule?
p {
width: 300px;
color: red;
} (a) width (b) .note (c) p (d) red - 39.✍️ CSS declarations go inside which brackets? (a) < > (b) [ ] (c) ( ) (d) { }
-
40.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 18px;
}
}
Answer key
- orange
- 10
- False
- 40
- div
- blue
- 800px or wider
- Yes
- #ffffff
- the viewport meta tag
- flex-direction
- magenta
- bright green
- padding
- black
- No
- 20
- 60
- True
- False
- JavaScript
- :
- #0000ff
- yellow
- 330
- CSS
- 600px or narrower
- red
- display: flex
- makes headings and lists
- sets colours and fonts
- fits every screen
- rounds box corners
- 3
- True
- True
- h2
- p
- { }
- 18
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids