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?
<p class="red" id="main">Hi</p>
CSS:
.red { color: black; }
p { color: green; } (a) white (b) purple (c) green (d) black - 2.🌈 Which hex code is black? (a) #00ff00 (b) #ffffff (c) #000000 (d) #00ffff
-
3.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 190px;
padding: 20px;
border: 3px solid black;
margin: 5px;
} -
4.⚖️ What colour is the text of this element?
<p class="star" id="top">Hi</p>
CSS:
#top { color: red; }
.star { color: black; }
p { color: purple; } (a) black (b) red (c) purple (d) white -
5.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 1024px) {
p {
font-size: 26px;
}
} - 6.📱 Responsive design means a page ___. (a) is only for laptops (b) never changes (c) has no pictures (d) fits every screen
-
7.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 600px) {
p {
font-size: 22px;
}
} - 8.Which of these does HTML do? (a) changes the page live (b) makes headings and lists (c) reacts to a button click (d) adds space around boxes
- 9.🌈 Which colour of light is strongest in rgb(68, 184, 18)? (a) red (b) blue (c) green
- 10.🎯 Which element does the selector .big style? (a) <h2 class="box"> (b) <h1 class="red"> (c) <h1 class="big"> (d) <h1 id="big">
-
11.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 12px;
}
} (a) Yes (b) No -
12.🖌️ Where does the text sit on its line?
li {
text-align: left;
color: yellow;
font-size: 20px;
background-color: red;
} (a) on the right (b) in the middle (c) on the left - 13.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
-
14.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 230px;
justify-content: flex-start;
}
Inside are 4 boxes, each 50px wide (no margins). - 15.🎯 What kind of selector is #hero? (a) a class selector (b) an id selector (c) an element selector
-
16.⚖️ What colour is the text of this element?
<h2 class="star" id="intro">Hi</h2>
CSS:
h2 { color: red; }
h2 { color: purple; } (a) red (b) purple (c) blue (d) orange - 17.💪 Which flexbox property turns on flexbox? (a) display: flex (b) flex-direction (c) align-items (d) gap
- 18.Which of these does HTML do? (a) lays out the page (b) changes the page live (c) shows a pop-up message (d) makes a link
- 19.✍️ Which sign goes between a property and its value? (a) ; (b) - (c) = (d) :
- 20.🧩 Which language rounds box corners? (a) CSS (b) HTML (c) JavaScript
- 21.🌈 Which colour is rgb(255, 255, 255)? (a) cyan (b) magenta (c) red (d) white
- 22.🌈 In #rrggbb, which colour do the first two digits give? (a) blue (b) red (c) green (d) black
- 23.💪 Which flexbox property sets space between boxes? (a) justify-content (b) gap (c) flex-direction (d) display: flex
-
24.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 60px;
padding: 5px;
border: 2px solid black;
margin: 15px;
} - 25.🌈 Which hex code is white? (a) #0000ff (b) #ffffff (c) #000000 (d) #00ff00
- 26.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the first one (c) the later one (d) neither
- 27.True or false: JavaScript makes headings and lists. (a) True (b) False
- 28.💪 Which flexbox property lines boxes up across? (a) justify-content (b) gap (c) flex-direction (d) align-items
-
29.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 200px;
justify-content: center;
}
Inside are 3 boxes, each 60px wide (no margins). -
30.🎯 Which CSS selector matches this element?
<h1 class="red" id="logo">Hello</h1> (a) h2 (b) .logo (c) .box (d) #logo -
31.⚖️ What colour is the text of this element?
<p class="big" id="hero">Hi</p>
CSS:
p { color: purple; }
p { color: green; } (a) blue (b) black (c) green (d) purple - 32.True or false: margin is the gap to other boxes. (a) False (b) True
-
33.⚖️ What colour is the text of this element?
<p class="big" id="top">Hi</p>
CSS:
.big { color: yellow; }
.big { color: red; } (a) orange (b) red (c) yellow (d) blue - 34.True or false: #end is a class selector. (a) True (b) False
- 35.🌈 Which colour of light is strongest in rgb(240, 90, 82)? (a) red (b) blue (c) green
- 36.🌈 Which hex code is cyan? (a) #ff00ff (b) #ff0000 (c) #00ffff (d) #00ff00
-
37.⚖️ What colour is the text of this element?
<h1 class="menu" id="end">Hi</h1>
CSS:
.menu { color: green; }
h1 { color: black; } (a) green (b) white (c) red (d) black -
38.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 140px;
justify-content: flex-end;
}
Inside are 2 boxes, each 50px wide (no margins). - 39.🌈 Which colour is rgb(255, 0, 255)? (a) magenta (b) yellow (c) bright green (d) blue
- 40.🔍 Which is the odd one out? (a) gives the page structure (b) sets colours and fonts (c) makes headings and lists (d) makes a form box
Answer key
- black
- #000000
- 246
- red
- 26
- fits every screen
- 22
- makes headings and lists
- green
- <h1 class="big">
- Yes
- on the left
- an element selector
- 30
- an id selector
- purple
- display: flex
- makes a link
- :
- CSS
- white
- red
- gap
- 74
- #ffffff
- the later one
- False
- align-items
- 10
- #logo
- green
- True
- red
- False
- red
- #00ffff
- green
- 40
- magenta
- sets colours and fonts
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids