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.True or false: the border is the line round the box. (a) False (b) True
-
2.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 8px;
}
} (a) No (b) Yes -
3.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 32px;
}
} (a) No (b) Yes -
4.🖌️ What colour is behind the letters?
h2 {
text-align: center;
color: black;
background-color: purple;
font-size: 16px;
} (a) purple (b) blue (c) black - 5.📦 In the box model, which part is the gap round content? (a) border (b) margin (c) content (d) padding
-
6.✍️ What is the selector in this CSS rule?
h1 {
font-size: 20px;
margin: 10px;
} (a) p (b) h1 (c) font-size (d) 10px - 7.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) turned off (c) exactly 1000px (d) 600px or narrower
- 8.🌈 Which colour is #ffff00? (a) magenta (b) bright green (c) yellow (d) cyan
-
9.⚖️ What colour is the text of this element?
<p class="star" id="top">Hi</p>
CSS:
.star { color: red; }
.star { color: green; } (a) red (b) white (c) black (d) green -
10.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 270px;
padding: 30px;
border: 1px solid black;
margin: 0px;
} -
11.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 130px;
justify-content: flex-start;
}
Inside are 3 boxes, each 40px wide (no margins). -
12.✍️ How many declarations (property: value pairs) are in this rule?
p {
padding: 8px;
border: 2px solid;
color: red;
} - 13.🌈 Which colour of light is strongest in rgb(215, 60, 118)? (a) green (b) blue (c) red
- 14.🖌️ Which CSS property picks the font style? (a) background-color (b) font-family (c) text-align (d) font-weight
-
15.⚖️ What colour is the text of this element?
<h2 class="star" id="intro">Hi</h2>
CSS:
.star { color: white; }
h2 { color: black; }
#intro { color: blue; } (a) red (b) white (c) blue (d) black - 16.📦 In the box model, which part is the text or picture? (a) margin (b) border (c) content (d) padding
-
17.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 180px;
justify-content: flex-end;
}
Inside are 4 boxes, each 40px wide (no margins). -
18.🖌️ What colour are the letters?
h2 {
font-size: 16px;
color: red;
text-align: left;
background-color: blue;
} (a) red (b) purple (c) blue -
19.🖌️ What colour is behind the letters?
h1 {
background-color: red;
font-size: 24px;
color: black;
text-align: left;
} (a) yellow (b) black (c) red - 20.Which of these is the border? (a) the text or picture (b) space inside the border (c) the gap round content (d) a solid or dotted edge
- 21.🌈 What is the biggest number one colour can have in rgb()? (a) 100 (b) 99 (c) 255 (d) 1000
- 22.🌈 Which colour is rgb(0, 0, 0)? (a) blue (b) black (c) yellow (d) white
- 23.💪 Which justify-content value puts boxes in the middle? (a) space-between (b) center (c) flex-end (d) flex-start
- 24.💪 Which flexbox property picks row or column? (a) flex-direction (b) justify-content (c) align-items (d) gap
- 25.What does justify-content: flex-start do? (a) packs boxes at the start (b) equal gaps, none at ends (c) packs boxes at the end (d) puts boxes in the middle
-
26.🖌️ How big is the text, in px?
h2 {
background-color: red;
font-size: 40px;
text-align: left;
color: black;
} - 27.🎯 Which element does the selector #end style? (a) <p id="hero"> (b) <p id="end"> (c) <h1 class="star"> (d) <p class="end">
-
28.✍️ What is the selector in this CSS rule?
h1 {
color: red;
font-weight: bold;
background-color: yellow;
text-align: center;
} (a) h1 (b) bold (c) p (d) color - 29.True or false: the border is a solid or dotted edge. (a) True (b) False
- 30.🔍 Which is the odd one out? (a) gives the page structure (b) shows a pop-up message (c) makes headings and lists (d) makes a link
- 31.True or false: JavaScript changes the page live. (a) True (b) False
- 32.✍️ Which sign goes between a property and its value? (a) = (b) - (c) : (d) ;
- 33.🖌️ Which CSS property centres a heading? (a) font-family (b) background-color (c) text-align (d) color
-
34.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 2 boxes, each 50px wide (no margins). - 35.True or false: CSS gives the page structure. (a) False (b) True
- 36.📱 Responsive design means a page ___. (a) has no pictures (b) fits every screen (c) never changes (d) is only for laptops
- 37.🎯 What kind of selector is .menu? (a) an id selector (b) a class selector (c) an element selector
- 38.What does background-color do? (a) makes the text bold (b) makes letters bigger (c) colours behind the text (d) picks the font style
- 39.True or false: HTML checks a quiz answer. (a) False (b) True
- 40.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) neither (c) the first one (d) the shorter one
Answer key
- True
- Yes
- Yes
- purple
- padding
- h1
- 600px or narrower
- yellow
- green
- 332
- 10
- 3
- red
- font-family
- blue
- content
- 20
- red
- red
- a solid or dotted edge
- 255
- black
- center
- flex-direction
- packs boxes at the start
- 40
- <p id="end">
- h1
- True
- shows a pop-up message
- True
- :
- text-align
- 80
- False
- fits every screen
- a class selector
- colours behind the text
- False
- the later one
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids