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.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 18px;
}
} (a) No (b) Yes -
2.⚖️ What colour is the text of this element?
<h1 class="star" id="hero">Hi</h1>
CSS:
#hero { color: green; }
#hero { color: red; } (a) red (b) blue (c) black (d) green -
3.⚖️ What colour is the text of this element?
<p class="note" id="main">Hi</p>
CSS:
p { color: red; }
p { color: white; } (a) red (b) green (c) black (d) white - 4.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
-
5.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 300px;
justify-content: space-between;
}
Inside are 3 boxes, each 60px wide (no margins). -
6.🖌️ What colour are the letters?
h1 {
text-align: right;
background-color: red;
color: orange;
font-size: 36px;
} (a) purple (b) orange (c) red - 7.True or false: JavaScript sets colours and fonts. (a) True (b) False
-
8.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 6px;
}
} (a) Yes (b) No - 9.🎨 What does CSS stand for? (a) Computer Style Sheets (b) Creative Sheet System (c) Cascading Style Sheets (d) Colourful Site Styles
- 10.🌈 In #0000d1 the blue part is the hex number d1. What is it as a normal number?
- 11.🎨 One CSS file can style how many pages? (a) many pages (b) only one image (c) only one word (d) no pages
-
12.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 260px;
padding: 5px;
border: 4px solid black;
margin: 0px;
} -
13.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 320px;
justify-content: center;
}
Inside are 4 boxes, each 40px wide (no margins). -
14.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 110px;
justify-content: flex-start;
}
Inside are 2 boxes, each 40px wide (no margins). -
15.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 100px;
padding: 5px;
border: 2px solid black;
margin: 15px;
} - 16.True or false: #hero is an id selector. (a) True (b) False
- 17.True or false: p is an id selector. (a) True (b) False
- 18.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the title tag (c) the br tag (d) the viewport meta tag
- 19.What does text-align do? (a) sets the letter colour (b) colours behind the text (c) picks the font style (d) centres a heading
- 20.🎯 What kind of selector is p? (a) an id selector (b) a class selector (c) an element selector
- 21.🧩 Which language makes a link? (a) CSS (b) HTML (c) JavaScript
-
22.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 8px;
}
} -
23.⚖️ What colour is the text of this element?
<h1 class="star" id="top">Hi</h1>
CSS:
.star { color: black; }
.star { color: blue; } (a) green (b) blue (c) black (d) white -
24.✍️ What value is given to text-align in this rule?
.box {
width: 300px;
text-align: center;
font-size: 20px;
} (a) center (b) 10px (c) text-align (d) yellow -
25.⚖️ What colour is the text of this element?
<h2 class="note" id="end">Hi</h2>
CSS:
h2 { color: orange; }
h2 { color: blue; } (a) blue (b) orange (c) purple (d) white - 26.🌈 Which colour is rgb(0, 0, 0)? (a) cyan (b) bright green (c) black (d) blue
- 27.🎯 Which element does the selector h1 style? (a) <div id="main"> (b) <h1 class="note"> (c) <h2> (d) <li class="note">
- 28.🎯 What kind of selector is h1? (a) a class selector (b) an id selector (c) an element selector
- 29.🎯 Which element does the selector .red style? (a) <h2 class="star"> (b) <h1 class="box"> (c) <h1 id="red"> (d) <h1 class="red">
- 30.💪 Which justify-content value packs boxes at the end? (a) flex-end (b) flex-start (c) center (d) space-between
- 31.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
-
32.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 22px;
}
} (a) Yes (b) No -
33.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 320px;
justify-content: space-between;
}
Inside are 3 boxes, each 60px wide (no margins). - 34.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) turned off (c) exactly 1000px (d) 600px or narrower
- 35.What does justify-content: center do? (a) puts boxes in the middle (b) packs boxes at the end (c) packs boxes at the start (d) equal gaps, none at ends
- 36.📱 What does a media query check? (a) the screen width (b) the page title (c) the time of day (d) the battery level
- 37.🧩 Which language counts down a timer? (a) JavaScript (b) HTML (c) CSS
-
38.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
border: 2px solid;
} - 39.What does justify-content: space-between do? (a) equal gaps, none at ends (b) packs boxes at the end (c) packs boxes at the start (d) puts boxes in the middle
- 40.🧩 Which language changes the page live? (a) HTML (b) CSS (c) JavaScript
Answer key
- No
- red
- white
- an id selector
- 60
- orange
- False
- Yes
- Cascading Style Sheets
- 209
- many pages
- 278
- 80
- 30
- 144
- True
- False
- the viewport meta tag
- centres a heading
- an element selector
- HTML
- 8
- blue
- center
- blue
- black
- <h1 class="note">
- an element selector
- <h1 class="red">
- flex-end
- an element selector
- Yes
- 70
- 600px or narrower
- puts boxes in the middle
- the screen width
- JavaScript
- 1
- equal gaps, none at ends
- JavaScript
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids