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 flexbox property turns on flexbox? (a) justify-content (b) gap (c) display: flex (d) flex-direction
-
2.✍️ What is the selector in this CSS rule?
h2 {
text-align: center;
color: red;
font-style: italic;
} (a) h1 (b) h2 (c) text-align (d) red - 3.Which of these does HTML do? (a) reacts to a button click (b) shows a pop-up message (c) makes a form box (d) adds space around boxes
- 4.What does justify-content: space-between do? (a) packs boxes at the end (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the start
- 5.True or false: JavaScript checks a quiz answer. (a) True (b) False
-
6.⚖️ What colour is the text of this element?
<h2 class="big" id="logo">Hi</h2>
CSS:
#logo { color: orange; }
#logo { color: green; } (a) blue (b) orange (c) red (d) green - 7.📦 In the box model, which part is the gap to other boxes? (a) content (b) margin (c) padding (d) border
- 8.💪 Which flexbox property sets space between boxes? (a) align-items (b) gap (c) justify-content (d) display: flex
- 9.✍️ CSS declarations go inside which brackets? (a) < > (b) ( ) (c) { } (d) [ ]
-
10.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 260px;
justify-content: flex-start;
}
Inside are 4 boxes, each 60px wide (no margins). -
11.✍️ What is the selector in this CSS rule?
.box {
margin: 10px;
font-style: italic;
} (a) h2 (b) .box (c) margin (d) italic -
12.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 20px;
}
} (a) Yes (b) No - 13.True or false: CSS rounds box corners. (a) False (b) True
-
14.🖌️ What colour is behind the letters?
h2 {
text-align: right;
background-color: yellow;
font-size: 36px;
color: red;
} (a) orange (b) red (c) yellow - 15.🧩 Which language puts a picture on a page? (a) HTML (b) JavaScript (c) CSS
-
16.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 280px;
padding: 20px;
border: 2px solid black;
margin: 0px;
} - 17.🖌️ Which CSS property makes the text bold? (a) font-family (b) text-align (c) background-color (d) font-weight
-
18.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 230px;
padding: 30px;
border: 5px solid black;
margin: 15px;
} -
19.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 280px;
padding: 20px;
border: 2px solid black;
margin: 0px;
} -
20.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 190px;
justify-content: flex-start;
}
Inside are 2 boxes, each 60px wide (no margins). -
21.⚖️ What colour is the text of this element?
<h2 class="big" id="main">Hi</h2>
CSS:
h2 { color: blue; }
h2 { color: orange; } (a) orange (b) blue (c) yellow (d) green -
22.⚖️ What colour is the text of this element?
<h2 class="menu" id="logo">Hi</h2>
CSS:
.menu { color: green; }
h2 { color: white; }
#logo { color: blue; } (a) blue (b) purple (c) green (d) white - 23.🎯 Which sign starts an id selector? (a) . (b) # (c) & (d) @
-
24.✍️ How many declarations (property: value pairs) are in this rule?
body {
padding: 8px;
margin: 10px;
border: 2px solid;
color: red;
} -
25.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
margin: 10px;
} - 26.True or false: img is a class selector. (a) True (b) False
- 27.💪 Which justify-content value equal gaps, none at ends? (a) space-between (b) flex-end (c) flex-start (d) center
- 28.Which of these is the content? (a) a solid or dotted edge (b) the line round the box (c) space inside the border (d) the text or picture
- 29.What does font-family do? (a) colours behind the text (b) picks the font style (c) makes the text bold (d) centres a heading
-
30.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} - 31.🌈 In #010000 the red part is the hex number 01. What is it as a normal number?
- 32.🌈 Which colour of light is strongest in rgb(200, 126, 42)? (a) red (b) green (c) blue
-
33.🖌️ What colour is behind the letters?
p {
color: purple;
text-align: center;
background-color: yellow;
font-size: 36px;
} (a) yellow (b) purple (c) blue - 34.🎨 Which attribute adds CSS inside one tag? (a) style (b) href (c) src (d) alt
- 35.🌈 Which hex code is blue? (a) #00ffff (b) #0000ff (c) #00ff00 (d) #ffffff
-
36.⚖️ What colour is the text of this element?
<p class="note" id="main">Hi</p>
CSS:
p { color: red; }
#main { color: yellow; } (a) blue (b) orange (c) red (d) yellow -
37.⚖️ What colour is the text of this element?
<p class="box" id="top">Hi</p>
CSS:
p { color: orange; }
p { color: blue; } (a) black (b) blue (c) green (d) orange -
38.🖌️ What colour are the letters?
h1 {
font-size: 16px;
text-align: left;
color: black;
background-color: red;
} (a) black (b) red (c) blue - 39.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) exactly 100px (c) 800px or wider (d) 800px or narrower
-
40.🎯 Which CSS selector matches this element?
<div class="red" id="top">Hello</div> (a) #intro (b) .red (c) .box (d) #red
Answer key
- display: flex
- h2
- makes a form box
- equal gaps, none at ends
- True
- green
- margin
- gap
- { }
- 20
- .box
- No
- True
- yellow
- HTML
- 324
- font-weight
- 300
- 324
- 70
- orange
- blue
- #
- 4
- 1
- False
- space-between
- the text or picture
- picks the font style
- 18
- 1
- red
- yellow
- style
- #0000ff
- yellow
- blue
- black
- 800px or wider
- .red
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids