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.🖌️ Where does the text sit on its line?
p {
background-color: yellow;
text-align: center;
color: purple;
font-size: 32px;
} (a) in the middle (b) on the left (c) on the right - 2.Which of these does HTML do? (a) sets colours and fonts (b) reacts to a button click (c) adds space around boxes (d) makes a form box
-
3.⚖️ What colour is the text of this element?
<h2 class="menu" id="top">Hi</h2>
CSS:
.menu { color: black; }
#top { color: green; } (a) green (b) orange (c) purple (d) black -
4.✍️ Which property is set to 20px in this rule?
h2 {
margin: 10px;
font-size: 20px;
font-weight: bold;
} (a) 20px (b) background-color (c) font-size (d) text-align -
5.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 6px;
}
} -
6.✍️ What is the selector in this CSS rule?
body {
border: 2px solid;
width: 300px;
} (a) .box (b) body (c) border (d) 300px -
7.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 200px;
justify-content: flex-end;
}
Inside are 3 boxes, each 50px wide (no margins). -
8.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 50px;
padding: 10px;
border: 1px solid black;
margin: 20px;
} - 9.📦 In the box model, which part is the text or picture? (a) border (b) content (c) margin (d) padding
-
10.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 28px;
}
} - 11.Which of these does CSS do? (a) gives the page structure (b) makes a link (c) reacts to a button click (d) lays out the page
-
12.🖌️ Where does the text sit on its line?
h1 {
text-align: center;
background-color: black;
font-size: 36px;
color: orange;
} (a) on the right (b) in the middle (c) on the left -
13.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 14px;
}
} (a) Yes (b) No - 14.🌈 In #150000 the red part is the hex number 15. What is it as a normal number?
-
15.⚖️ What colour is the text of this element?
<h1 class="box" id="logo">Hi</h1>
CSS:
#logo { color: orange; }
h1 { color: black; } (a) black (b) orange (c) yellow (d) purple -
16.⚖️ What colour is the text of this element?
<p class="box" id="logo">Hi</p>
CSS:
#logo { color: yellow; }
#logo { color: white; } (a) red (b) white (c) yellow (d) blue - 17.What does font-weight do? (a) centres a heading (b) makes letters bigger (c) makes the text bold (d) picks the font style
-
18.🖌️ What colour is behind the letters?
h2 {
color: green;
text-align: center;
background-color: blue;
font-size: 40px;
} (a) blue (b) black (c) green - 19.🎯 Which sign starts an id selector? (a) . (b) & (c) # (d) @
-
20.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 480px) {
p {
font-size: 14px;
}
} - 21.✍️ Which sign ends each CSS declaration? (a) . (b) ; (c) : (d) ,
- 22.True or false: JavaScript lays out the page. (a) True (b) False
- 23.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) exactly 100px (c) 800px or wider (d) turned off
- 24.🎯 Which element does the selector .big style? (a) <p class="box"> (b) <span class="big"> (c) <span id="big"> (d) <span class="red">
- 25.🌈 Which hex code is red? (a) #00ff00 (b) #ff0000 (c) #ffff00 (d) #00ffff
-
26.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 140px;
padding: 20px;
border: 4px solid black;
margin: 5px;
} - 27.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) neither (c) the later one (d) the first one
- 28.🌈 Which colour is rgb(0, 255, 0)? (a) blue (b) yellow (c) bright green (d) red
- 29.🎯 Can many elements share the same class? (a) No (b) Yes
- 30.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
-
31.🖌️ Where does the text sit on its line?
h1 {
color: yellow;
background-color: red;
font-size: 16px;
text-align: left;
} (a) in the middle (b) on the right (c) on the left - 32.✍️ CSS declarations go inside which brackets? (a) < > (b) ( ) (c) [ ] (d) { }
- 33.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) green (c) white (d) red
- 34.True or false: li is an id selector. (a) True (b) False
- 35.🌈 Which hex code is blue? (a) #ffffff (b) #00ffff (c) #0000ff (d) #ffff00
- 36.🔍 Which is the odd one out? (a) rounds box corners (b) adds space around boxes (c) makes a link (d) sets colours and fonts
-
37.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 190px;
padding: 30px;
border: 1px solid black;
margin: 10px;
} -
38.🖌️ Where does the text sit on its line?
li {
color: red;
background-color: blue;
text-align: center;
font-size: 28px;
} (a) on the right (b) in the middle (c) on the left - 39.📱 What does a media query check? (a) the screen width (b) the battery level (c) the time of day (d) the page title
- 40.🌈 Hex digits go 0 to 9, then A to which letter? (a) Z (b) J (c) F (d) G
Answer key
- in the middle
- makes a form box
- green
- font-size
- 12
- body
- 50
- 112
- content
- 20
- lays out the page
- in the middle
- Yes
- 21
- orange
- white
- makes the text bold
- blue
- #
- 14
- ;
- False
- 800px or wider
- <span class="big">
- #ff0000
- 198
- the later one
- bright green
- Yes
- an element selector
- on the left
- { }
- blue
- False
- #0000ff
- makes a link
- 252
- in the middle
- the screen width
- F
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids