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.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 170px;
justify-content: space-between;
}
Inside are 3 boxes, each 50px wide (no margins). - 2.🎯 Which sign starts an id selector? (a) . (b) @ (c) # (d) &
- 3.🧩 Which language makes headings and lists? (a) HTML (b) CSS (c) JavaScript
-
4.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 160px;
justify-content: space-between;
}
Inside are 3 boxes, each 40px wide (no margins). -
5.✍️ What value is given to background-color in this rule?
body {
text-align: center;
background-color: yellow;
width: 300px;
} (a) 8px (b) yellow (c) 10px (d) background-color - 6.💪 Which flexbox property sets space between boxes? (a) flex-direction (b) gap (c) display: flex (d) justify-content
-
7.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 370px;
justify-content: space-between;
}
Inside are 4 boxes, each 40px wide (no margins). - 8.What does justify-content: flex-start do? (a) packs boxes at the end (b) packs boxes at the start (c) puts boxes in the middle (d) equal gaps, none at ends
- 9.🖌️ Which CSS property centres a heading? (a) font-family (b) font-size (c) text-align (d) font-weight
- 10.What does justify-content: center do? (a) puts boxes in the middle (b) equal gaps, none at ends (c) packs boxes at the start (d) packs boxes at the end
-
11.🖌️ Where does the text sit on its line?
p {
font-size: 24px;
background-color: green;
color: blue;
text-align: left;
} (a) on the left (b) on the right (c) in the middle - 12.💪 Which flexbox property spaces boxes along a row? (a) flex-direction (b) display: flex (c) align-items (d) justify-content
-
13.✍️ What is the selector in this CSS rule?
#top {
width: 300px;
color: red;
} (a) li (b) width (c) #top (d) red - 14.🌈 Which colour of light is strongest in rgb(13, 204, 9)? (a) red (b) green (c) blue
- 15.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) exactly 100px (c) 800px or wider (d) 800px or narrower
-
16.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 8px;
}
} (a) No (b) Yes - 17.🎯 What kind of selector is h1? (a) an id selector (b) a class selector (c) an element selector
-
18.🖌️ Where does the text sit on its line?
p {
color: green;
text-align: left;
font-size: 28px;
background-color: red;
} (a) on the right (b) in the middle (c) on the left - 19.✍️ How does a CSS comment start? (a) /* (b) # (c) // (d) <!--
-
20.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 160px;
justify-content: flex-end;
}
Inside are 2 boxes, each 50px wide (no margins). -
21.✍️ What value is given to margin in this rule?
.box {
margin: 10px;
font-weight: bold;
} (a) 8px (b) margin (c) bold (d) 10px -
22.✍️ What is the selector in this CSS rule?
body {
font-size: 20px;
text-align: center;
} (a) center (b) body (c) .box (d) font-size -
23.✍️ How many declarations (property: value pairs) are in this rule?
.note {
text-align: center;
} - 24.True or false: h1 is a class selector. (a) False (b) True
- 25.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or narrower (c) 600px or wider (d) turned off
-
26.🖌️ How big is the text, in px?
p {
color: blue;
text-align: left;
font-size: 28px;
background-color: green;
} - 27.📦 In the box model, which part is space outside the border? (a) padding (b) border (c) margin (d) content
- 28.📱 What does a media query check? (a) the page title (b) the time of day (c) the screen width (d) the battery level
- 29.💪 Which justify-content value equal gaps, none at ends? (a) flex-start (b) space-between (c) flex-end (d) center
-
30.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 200px;
justify-content: flex-end;
}
Inside are 4 boxes, each 40px wide (no margins). - 31.🖌️ Which CSS property colours behind the text? (a) background-color (b) font-size (c) font-family (d) color
-
32.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 768px) {
p {
font-size: 14px;
}
} (a) No (b) Yes -
33.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 14px;
}
} (a) No (b) Yes - 34.🎯 Which sign starts a class selector? (a) @ (b) & (c) . (d) #
-
35.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 16px;
}
} - 36.🌈 Which colour is rgb(255, 255, 0)? (a) cyan (b) black (c) yellow (d) white
-
37.⚖️ What colour is the text of this element?
<p class="big" id="logo">Hi</p>
CSS:
#logo { color: blue; }
#logo { color: purple; } (a) red (b) blue (c) purple (d) orange -
38.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 10px;
}
} (a) No (b) Yes -
39.✍️ What value is given to background-color in this rule?
h2 {
margin: 10px;
background-color: yellow;
} (a) yellow (b) 10px (c) 8px (d) background-color - 40.🎯 How many elements on a page should have the same id? (a) 5 (b) 1 (c) any number (d) 2
Answer key
- 10
- #
- HTML
- 20
- yellow
- gap
- 70
- packs boxes at the start
- text-align
- puts boxes in the middle
- on the left
- justify-content
- #top
- green
- 800px or wider
- Yes
- an element selector
- on the left
- /*
- 60
- 10px
- body
- 1
- False
- 600px or narrower
- 28
- margin
- the screen width
- space-between
- 40
- background-color
- Yes
- Yes
- .
- 16
- yellow
- purple
- No
- yellow
- 1
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids