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: purple;
color: white;
text-align: left;
font-size: 16px;
} (a) in the middle (b) on the right (c) on the left -
2.⚖️ What colour is the text of this element?
<h1 class="red" id="main">Hi</h1>
CSS:
.red { color: yellow; }
#main { color: blue; } (a) yellow (b) orange (c) red (d) blue -
3.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 80px;
padding: 15px;
border: 3px solid black;
margin: 0px;
} -
4.🖌️ What colour are the letters?
p {
font-size: 20px;
text-align: right;
color: orange;
background-color: yellow;
} (a) yellow (b) red (c) orange - 5.What does justify-content: center do? (a) puts boxes in the middle (b) packs boxes at the start (c) packs boxes at the end (d) equal gaps, none at ends
-
6.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 6px;
}
} -
7.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 470px;
justify-content: space-between;
}
Inside are 4 boxes, each 80px wide (no margins). - 8.📱 What does a media query check? (a) the page title (b) the battery level (c) the time of day (d) the screen width
-
9.⚖️ What colour is the text of this element?
<h2 class="star" id="hero">Hi</h2>
CSS:
h2 { color: white; }
.star { color: black; }
#hero { color: purple; } (a) yellow (b) black (c) purple (d) white - 10.✍️ Which sign goes between a property and its value? (a) ; (b) = (c) - (d) :
-
11.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 190px;
justify-content: space-between;
}
Inside are 2 boxes, each 80px wide (no margins). - 12.Which of these does HTML do? (a) rounds box corners (b) changes the text size (c) changes the page live (d) makes a link
-
13.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 310px;
justify-content: flex-end;
}
Inside are 3 boxes, each 80px wide (no margins). - 14.🌈 Which colour is rgb(255, 255, 0)? (a) yellow (b) magenta (c) cyan (d) white
-
15.⚖️ What colour is the text of this element?
<h1 class="note" id="top">Hi</h1>
CSS:
.note { color: purple; }
h1 { color: green; } (a) red (b) green (c) purple (d) orange - 16.Which of these does JavaScript do? (a) rounds box corners (b) makes headings and lists (c) shows a pop-up message (d) adds space around boxes
-
17.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 24px;
}
} - 18.📦 In the box model, which part is the gap to other boxes? (a) margin (b) border (c) padding (d) content
- 19.🧩 Which language adds space around boxes? (a) JavaScript (b) CSS (c) HTML
- 20.📱 Responsive design means a page ___. (a) is only for laptops (b) never changes (c) fits every screen (d) has no pictures
- 21.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
- 22.✍️ How does a CSS comment start? (a) <!-- (b) # (c) // (d) /*
- 23.🎨 A CSS file usually ends with which extension? (a) .css (b) .html (c) .js (d) .png
- 24.True or false: the border is the line round the box. (a) False (b) True
-
25.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 250px;
padding: 25px;
border: 5px solid black;
margin: 20px;
} - 26.🎯 What kind of selector is #top? (a) a class selector (b) an id selector (c) an element selector
-
27.⚖️ What colour is the text of this element?
<h2 class="note" id="end">Hi</h2>
CSS:
#end { color: green; }
h2 { color: white; }
.note { color: yellow; } (a) green (b) white (c) yellow (d) orange -
28.⚖️ What colour is the text of this element?
<h1 class="box" id="end">Hi</h1>
CSS:
#end { color: blue; }
.box { color: red; } (a) black (b) red (c) purple (d) blue - 29.🖌️ Which CSS property makes letters bigger? (a) font-family (b) font-weight (c) font-size (d) text-align
-
30.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 14px;
}
} -
31.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 16px;
}
} -
32.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 120px;
justify-content: space-between;
}
Inside are 2 boxes, each 40px wide (no margins). -
33.✍️ Which property is set to 10px in this rule?
body {
border: 2px solid;
margin: 10px;
} (a) 10px (b) margin (c) font-weight (d) padding -
34.✍️ How many declarations (property: value pairs) are in this rule?
#top {
margin: 10px;
} -
35.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 360px;
justify-content: flex-start;
}
Inside are 4 boxes, each 80px wide (no margins). -
36.🖌️ What colour are the letters?
p {
text-align: right;
background-color: red;
font-size: 36px;
color: purple;
} (a) orange (b) purple (c) red - 37.🌈 Which colour of light is strongest in rgb(175, 11, 116)? (a) red (b) blue (c) green
-
38.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 1024px) {
p {
font-size: 14px;
}
} (a) Yes (b) No - 39.🖌️ Which CSS property colours behind the text? (a) font-family (b) background-color (c) font-weight (d) font-size
- 40.📱 min-width: 800px applies when the screen is ___. (a) 800px or wider (b) exactly 100px (c) 800px or narrower (d) turned off
Answer key
- on the left
- blue
- 116
- orange
- puts boxes in the middle
- 6
- 50
- the screen width
- purple
- :
- 30
- makes a link
- 70
- yellow
- purple
- shows a pop-up message
- 24
- margin
- CSS
- fits every screen
- an element selector
- /*
- .css
- True
- 310
- an id selector
- green
- blue
- font-size
- 20
- 20
- 40
- margin
- 1
- 40
- purple
- red
- Yes
- background-color
- 800px or wider
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids