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.⚖️ What colour is the text of this element?
<h1 class="star" id="top">Hi</h1>
CSS:
#top { color: white; }
h1 { color: yellow; }
.star { color: orange; } (a) white (b) yellow (c) red (d) orange -
2.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 230px;
justify-content: space-between;
}
Inside are 2 boxes, each 100px wide (no margins). -
3.✍️ Which property is set to 8px in this rule?
p {
text-align: center;
padding: 8px;
} (a) padding (b) border (c) font-weight (d) 8px - 4.💪 Which flexbox property turns on flexbox? (a) gap (b) justify-content (c) flex-direction (d) display: flex
-
5.🎯 Which CSS selector matches this element?
<p class="note" id="end">Hello</p> (a) .end (b) h1 (c) #note (d) .note - 6.✍️ Which sign goes between a property and its value? (a) - (b) = (c) ; (d) :
- 7.🌈 Which colour is rgb(0, 0, 0)? (a) cyan (b) red (c) black (d) blue
- 8.Which of these does JavaScript do? (a) reacts to a button click (b) gives the page structure (c) puts a picture on a page (d) changes the text size
- 9.🎯 Can many elements share the same class? (a) Yes (b) No
- 10.🖌️ Which CSS property sets the letter colour? (a) font-family (b) text-align (c) background-color (d) color
- 11.🔍 Which is the odd one out? (a) lays out the page (b) sets colours and fonts (c) rounds box corners (d) shows a pop-up message
- 12.🌈 Which colour is rgb(0, 255, 255)? (a) black (b) bright green (c) cyan (d) red
- 13.🌈 Which colour is #ffff00? (a) yellow (b) white (c) magenta (d) red
-
14.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 32px;
}
} (a) Yes (b) No -
15.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 28px;
}
} (a) No (b) Yes - 16.What does justify-content: space-between do? (a) puts boxes in the middle (b) packs boxes at the end (c) packs boxes at the start (d) equal gaps, none at ends
-
17.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 150px;
padding: 20px;
border: 2px solid black;
margin: 5px;
} - 18.🌈 Which colour is rgb(255, 0, 255)? (a) magenta (b) red (c) black (d) cyan
-
19.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 100px;
justify-content: space-between;
}
Inside are 2 boxes, each 40px wide (no margins). -
20.🎯 Which CSS selector matches this element?
<h2 class="star" id="logo">Hello</h2> (a) li (b) h2 (c) #end (d) #star - 21.What does font-size do? (a) colours behind the text (b) makes letters bigger (c) picks the font style (d) sets the letter colour
- 22.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
- 23.🔍 Which is the odd one out? (a) makes a link (b) puts a picture on a page (c) makes a form box (d) rounds box corners
-
24.✍️ What value is given to font-size in this rule?
h2 {
width: 300px;
font-size: 20px;
} (a) yellow (b) center (c) font-size (d) 20px -
25.🎯 Which CSS selector matches this element?
<h1 class="box" id="intro">Hello</h1> (a) h2 (b) .star (c) .intro (d) h1 -
26.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 18px;
}
} - 27.Which of these is the content? (a) space outside the border (b) the text or picture (c) space inside the border (d) the line round the box
-
28.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 140px;
justify-content: flex-end;
}
Inside are 3 boxes, each 40px wide (no margins). - 29.🌈 In #rrggbb, which colour do the first two digits give? (a) black (b) blue (c) green (d) red
- 30.True or false: CSS lays out the page. (a) False (b) True
- 31.🔍 Which is the odd one out? (a) puts a picture on a page (b) reacts to a button click (c) makes headings and lists (d) makes a form box
- 32.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) blue (c) white (d) red
- 33.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) exactly 1000px (c) 600px or narrower (d) 600px or wider
- 34.📱 Which tag helps phones show a page at the right size? (a) the viewport meta tag (b) the hr tag (c) the title tag (d) the br tag
- 35.🖌️ Which CSS property makes the text bold? (a) font-size (b) font-family (c) font-weight (d) text-align
-
36.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 280px;
padding: 20px;
border: 2px solid black;
margin: 15px;
} -
37.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 16px;
}
} -
38.🖌️ What colour is behind the letters?
li {
color: purple;
font-size: 28px;
text-align: right;
background-color: green;
} (a) green (b) purple (c) blue -
39.⚖️ What colour is the text of this element?
<p class="box" id="top">Hi</p>
CSS:
p { color: white; }
.box { color: purple; } (a) white (b) black (c) purple (d) red - 40.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
Answer key
- white
- 30
- padding
- display: flex
- .note
- :
- black
- reacts to a button click
- Yes
- color
- shows a pop-up message
- cyan
- yellow
- No
- No
- equal gaps, none at ends
- 204
- magenta
- 20
- h2
- makes letters bigger
- an id selector
- rounds box corners
- 20px
- h1
- 12
- the text or picture
- 20
- red
- True
- reacts to a button click
- blue
- 600px or narrower
- the viewport meta tag
- font-weight
- 354
- 12
- green
- purple
- an element selector
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids