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.Which of these is the border? (a) space inside the border (b) space outside the border (c) the text or picture (d) the line round the box
-
2.⚖️ What colour is the text of this element?
<h2 class="big" id="intro">Hi</h2>
CSS:
.big { color: orange; }
.big { color: white; } (a) green (b) white (c) blue (d) orange - 3.💪 Which justify-content value packs boxes at the start? (a) space-between (b) flex-end (c) center (d) flex-start
- 4.🌈 Hex digits go 0 to 9, then A to which letter? (a) J (b) G (c) Z (d) F
-
5.🖌️ What colour is behind the letters?
p {
color: orange;
text-align: center;
font-size: 32px;
background-color: blue;
} (a) orange (b) blue (c) yellow -
6.✍️ What is the selector in this CSS rule?
h2 {
border: 2px solid;
font-style: italic;
margin: 10px;
} (a) h1 (b) h2 (c) border (d) italic -
7.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 16px;
}
} (a) Yes (b) No -
8.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 100px;
padding: 15px;
border: 4px solid black;
margin: 0px;
} -
9.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 14px;
}
} -
10.⚖️ What colour is the text of this element?
<h2 class="menu" id="logo">Hi</h2>
CSS:
.menu { color: orange; }
#logo { color: red; } (a) purple (b) blue (c) red (d) orange -
11.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 24px;
}
} - 12.🎯 Which sign starts an id selector? (a) @ (b) # (c) & (d) .
- 13.🌈 Which hex code is black? (a) #00ff00 (b) #000000 (c) #00ffff (d) #ffff00
-
14.⚖️ What colour is the text of this element?
<h1 class="note" id="top">Hi</h1>
CSS:
h1 { color: purple; }
.note { color: white; }
#top { color: yellow; } (a) yellow (b) purple (c) green (d) white -
15.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 12px;
}
} - 16.🖌️ Which CSS property sets the letter colour? (a) color (b) font-weight (c) background-color (d) font-family
-
17.✍️ How many declarations (property: value pairs) are in this rule?
.note {
border: 2px solid;
text-align: center;
font-style: italic;
} - 18.✍️ In color: blue; which part is the property? (a) blue (b) : (c) color (d) ;
-
19.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
font-style: italic;
color: red;
font-size: 20px;
} - 20.🧩 Which language makes headings and lists? (a) CSS (b) HTML (c) JavaScript
-
21.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 220px;
padding: 10px;
border: 4px solid black;
margin: 0px;
} -
22.✍️ Which property is set to 300px in this rule?
.note {
width: 300px;
color: red;
} (a) font-style (b) 300px (c) color (d) width - 23.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) exactly 1000px (c) 600px or wider (d) 600px or narrower
- 24.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) gap (c) justify-content (d) display: flex
- 25.What does justify-content: flex-end do? (a) packs boxes at the start (b) packs boxes at the end (c) equal gaps, none at ends (d) puts boxes in the middle
- 26.What does background-color do? (a) makes the text bold (b) sets the letter colour (c) colours behind the text (d) makes letters bigger
-
27.✍️ What is the selector in this CSS rule?
h1 {
background-color: yellow;
color: red;
} (a) red (b) background-color (c) p (d) h1 - 28.🎯 Which element does the selector h2 style? (a) <h2 class="star"> (b) <li> (c) <div class="star"> (d) <span id="intro">
- 29.🎯 Which sign starts a class selector? (a) # (b) . (c) @ (d) &
- 30.🔍 Which is the odd one out? (a) shows a pop-up message (b) counts down a timer (c) checks a quiz answer (d) adds space around boxes
-
31.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 22px;
}
} -
32.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 140px;
padding: 20px;
border: 1px solid black;
margin: 20px;
} - 33.🌈 Which hex code is magenta? (a) #00ff00 (b) #0000ff (c) #ffff00 (d) #ff00ff
- 34.True or false: #end is an id selector. (a) False (b) True
- 35.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the later one (c) neither (d) the first one
-
36.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 420px;
justify-content: space-between;
}
Inside are 3 boxes, each 100px wide (no margins). - 37.🌈 Which hex code is white? (a) #000000 (b) #ff00ff (c) #00ffff (d) #ffffff
- 38.🌈 In #rrggbb, which colour do the first two digits give? (a) red (b) blue (c) black (d) green
- 39.🧩 Which language adds space around boxes? (a) JavaScript (b) CSS (c) HTML
- 40.🎯 Can many elements share the same class? (a) Yes (b) No
Answer key
- the line round the box
- white
- flex-start
- F
- blue
- h2
- Yes
- 138
- 12
- red
- 20
- #
- #000000
- yellow
- 12
- color
- 3
- color
- 3
- HTML
- 248
- width
- 600px or narrower
- display: flex
- packs boxes at the end
- colours behind the text
- h1
- <h2 class="star">
- .
- adds space around boxes
- 22
- 222
- #ff00ff
- True
- the later one
- 60
- #ffffff
- red
- CSS
- Yes
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids