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 this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 300px;
padding: 15px;
border: 5px solid black;
margin: 10px;
} -
2.🖌️ Where does the text sit on its line?
li {
color: green;
font-size: 12px;
background-color: red;
text-align: right;
} (a) on the right (b) on the left (c) in the middle - 3.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) turned off (c) exactly 1000px (d) 600px or narrower
-
4.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 300px;
padding: 25px;
border: 4px solid black;
margin: 15px;
} - 5.🌈 Which colour of light is strongest in rgb(89, 0, 242)? (a) blue (b) green (c) red
- 6.📱 What does a media query check? (a) the screen width (b) the page title (c) the time of day (d) the battery level
-
7.✍️ How many declarations (property: value pairs) are in this rule?
.note {
font-style: italic;
color: red;
font-size: 20px;
width: 300px;
} -
8.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 20px;
}
} - 9.What does color do? (a) makes letters bigger (b) centres a heading (c) picks the font style (d) sets the letter colour
- 10.💪 Which flexbox property spaces boxes along a row? (a) display: flex (b) align-items (c) justify-content (d) flex-direction
- 11.What does justify-content: flex-end do? (a) puts boxes in the middle (b) packs boxes at the end (c) equal gaps, none at ends (d) packs boxes at the start
- 12.🖌️ Which CSS property colours behind the text? (a) font-weight (b) color (c) text-align (d) background-color
- 13.✍️ Which sign ends each CSS declaration? (a) : (b) , (c) . (d) ;
-
14.✍️ What value is given to font-size in this rule?
#top {
border: 2px solid;
font-size: 20px;
} (a) center (b) font-size (c) yellow (d) 20px - 15.✍️ In color: blue; which part is the property? (a) blue (b) ; (c) : (d) color
- 16.🔍 Which is the odd one out? (a) counts down a timer (b) shows a pop-up message (c) reacts to a button click (d) lays out the page
-
17.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 768px) {
p {
font-size: 28px;
}
} (a) Yes (b) No -
18.⚖️ What colour is the text of this element?
<p class="menu" id="top">Hi</p>
CSS:
p { color: green; }
p { color: purple; } (a) purple (b) black (c) white (d) green - 19.🎯 Can many elements share the same class? (a) Yes (b) No
- 20.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the later one (c) the shorter one (d) the first one
-
21.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 16px;
}
} -
22.⚖️ What colour is the text of this element?
<h2 class="note" id="logo">Hi</h2>
CSS:
h2 { color: purple; }
.note { color: black; }
#logo { color: white; } (a) purple (b) white (c) orange (d) black -
23.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 14px;
}
} (a) Yes (b) No -
24.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 130px;
padding: 25px;
border: 2px solid black;
margin: 15px;
} -
25.✍️ How many declarations (property: value pairs) are in this rule?
#top {
margin: 10px;
} - 26.🌈 Which colour of light is strongest in rgb(56, 226, 46)? (a) green (b) red (c) blue
- 27.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) white (c) red (d) green
-
28.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 8px;
}
} -
29.✍️ Which property is set to bold in this rule?
h2 {
color: red;
font-weight: bold;
border: 2px solid;
} (a) bold (b) border (c) font-weight (d) width -
30.⚖️ What colour is the text of this element?
<h1 class="red" id="top">Hi</h1>
CSS:
h1 { color: yellow; }
h1 { color: green; } (a) blue (b) green (c) orange (d) yellow - 31.🎯 Which element does the selector .star style? (a) <div class="star"> (b) <div id="star"> (c) <span class="note"> (d) <div class="menu">
- 32.📱 Responsive design means a page ___. (a) has no pictures (b) never changes (c) fits every screen (d) is only for laptops
- 33.💪 Which justify-content value equal gaps, none at ends? (a) flex-end (b) center (c) space-between (d) flex-start
- 34.What does font-family do? (a) makes letters bigger (b) centres a heading (c) picks the font style (d) makes the text bold
- 35.True or false: JavaScript adds space around boxes. (a) True (b) False
-
36.✍️ How many declarations (property: value pairs) are in this rule?
#top {
border: 2px solid;
} -
37.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 540px;
justify-content: center;
}
Inside are 4 boxes, each 100px wide (no margins). -
38.⚖️ What colour is the text of this element?
<p class="note" id="end">Hi</p>
CSS:
p { color: black; }
.note { color: purple; } (a) yellow (b) orange (c) black (d) purple -
39.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 3 boxes, each 80px wide (no margins). - 40.Which of these does CSS do? (a) sets colours and fonts (b) checks a quiz answer (c) puts a picture on a page (d) makes headings and lists
Answer key
- 340
- on the right
- 600px or narrower
- 388
- blue
- the screen width
- 4
- 24
- sets the letter colour
- justify-content
- packs boxes at the end
- background-color
- ;
- 20px
- color
- lays out the page
- Yes
- purple
- Yes
- the later one
- 12
- white
- Yes
- 214
- 1
- green
- blue
- 12
- font-weight
- green
- <div class="star">
- fits every screen
- space-between
- picks the font style
- False
- 1
- 70
- purple
- 10
- sets colours and fonts
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids