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.🌈 In #rrggbb, which colour do the first two digits give? (a) blue (b) green (c) red (d) black
- 2.📦 In the box model, which part is the line round the box? (a) padding (b) border (c) margin (d) content
- 3.📦 In the box model, which part is the gap round content? (a) border (b) content (c) padding (d) margin
-
4.⚖️ What colour is the text of this element?
<h2 class="star" id="hero">Hi</h2>
CSS:
#hero { color: red; }
h2 { color: black; } (a) black (b) red (c) orange (d) yellow -
5.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 280px;
justify-content: center;
}
Inside are 3 boxes, each 40px wide (no margins). - 6.🎯 Can many elements share the same class? (a) Yes (b) No
- 7.🔍 Which is the odd one out? (a) changes the page live (b) checks a quiz answer (c) reacts to a button click (d) puts a picture on a page
- 8.🌈 Hex digits go 0 to 9, then A to which letter? (a) F (b) Z (c) J (d) G
- 9.💪 Which flexbox property spaces boxes along a row? (a) gap (b) justify-content (c) display: flex (d) flex-direction
- 10.🎯 What kind of selector is .card? (a) an element selector (b) an id selector (c) a class selector
- 11.🎯 What kind of selector is .menu? (a) an id selector (b) an element selector (c) a class selector
- 12.✍️ In color: blue; which part is the property? (a) color (b) blue (c) : (d) ;
- 13.Which of these is padding? (a) space outside the border (b) a solid or dotted edge (c) the gap to other boxes (d) space inside the border
- 14.💪 Which justify-content value puts boxes in the middle? (a) space-between (b) flex-start (c) flex-end (d) center
- 15.Which of these is the content? (a) the text or picture (b) the gap to other boxes (c) a solid or dotted edge (d) the gap round content
-
16.✍️ How many declarations (property: value pairs) are in this rule?
li {
font-weight: bold;
margin: 10px;
width: 300px;
font-style: italic;
} - 17.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) turned off (c) exactly 1000px (d) 600px or narrower
- 18.True or false: CSS gives the page structure. (a) True (b) False
- 19.🌈 Which colour is #ffff00? (a) black (b) bright green (c) yellow (d) cyan
- 20.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the first one (c) the later one (d) the shorter one
-
21.⚖️ What colour is the text of this element?
<p class="note" id="intro">Hi</p>
CSS:
.note { color: purple; }
.note { color: blue; } (a) purple (b) blue (c) green (d) white - 22.🖌️ Which CSS property makes letters bigger? (a) text-align (b) font-weight (c) color (d) font-size
-
23.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
text-align: center;
color: red;
font-size: 20px;
background-color: yellow;
} -
24.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 22px;
}
} -
25.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 6px;
}
} (a) No (b) Yes - 26.🖌️ Which CSS property colours behind the text? (a) text-align (b) font-size (c) background-color (d) color
- 27.💪 Which flexbox property sets space between boxes? (a) justify-content (b) display: flex (c) gap (d) flex-direction
-
28.⚖️ What colour is the text of this element?
<p class="note" id="top">Hi</p>
CSS:
#top { color: orange; }
.note { color: blue; }
p { color: green; } (a) blue (b) white (c) orange (d) green - 29.🎯 Which element does the selector .red style? (a) <p class="red"> (b) <h1 class="star"> (c) <p class="box"> (d) <p id="red">
-
30.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 430px;
justify-content: flex-end;
}
Inside are 4 boxes, each 100px wide (no margins). - 31.🧩 Which language counts down a timer? (a) HTML (b) JavaScript (c) CSS
- 32.🔍 Which is the odd one out? (a) makes a form box (b) changes the text size (c) lays out the page (d) adds space around boxes
- 33.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
- 34.Which of these is margin? (a) space inside the border (b) the gap to other boxes (c) a solid or dotted edge (d) the line round the box
-
35.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 20px;
}
} (a) No (b) Yes - 36.🌈 Which hex code is black? (a) #ff0000 (b) #000000 (c) #ffff00 (d) #ffffff
-
37.⚖️ What colour is the text of this element?
<h1 class="red" id="intro">Hi</h1>
CSS:
.red { color: yellow; }
#intro { color: red; } (a) green (b) yellow (c) red (d) blue -
38.✍️ What value is given to padding in this rule?
body {
padding: 8px;
text-align: center;
} (a) padding (b) bold (c) 2px solid (d) 8px - 39.🌈 Which colour is #00ffff? (a) white (b) yellow (c) cyan (d) red
-
40.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 50px;
padding: 25px;
border: 3px solid black;
margin: 0px;
}
Answer key
- red
- border
- padding
- red
- 80
- Yes
- puts a picture on a page
- F
- justify-content
- a class selector
- a class selector
- color
- space inside the border
- center
- the text or picture
- 4
- 600px or narrower
- False
- yellow
- the later one
- blue
- font-size
- 4
- 22
- Yes
- background-color
- gap
- orange
- <p class="red">
- 30
- JavaScript
- makes a form box
- an element selector
- the gap to other boxes
- Yes
- #000000
- red
- 8px
- cyan
- 106
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids