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 is the selector in this CSS rule?
li {
border: 2px solid;
font-weight: bold;
font-style: italic;
} (a) bold (b) li (c) body (d) border -
2.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 190px;
padding: 10px;
border: 2px solid black;
margin: 15px;
} - 3.🌈 Which colour is rgb(0, 255, 0)? (a) red (b) bright green (c) yellow (d) white
- 4.📱 What does a media query check? (a) the battery level (b) the time of day (c) the screen width (d) the page title
-
5.✍️ How many declarations (property: value pairs) are in this rule?
li {
color: red;
background-color: yellow;
} - 6.🌈 In #460000 the red part is the hex number 46. What is it as a normal number?
-
7.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 18px;
}
} (a) Yes (b) No -
8.🖌️ How big is the text, in px?
h2 {
text-align: right;
color: yellow;
background-color: red;
font-size: 16px;
} -
9.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 100px;
padding: 10px;
border: 5px solid black;
margin: 20px;
} - 10.🌈 Which colour is #ffffff? (a) bright green (b) white (c) red (d) magenta
-
11.🖌️ How big is the text, in px?
p {
text-align: right;
color: yellow;
background-color: red;
font-size: 24px;
} -
12.✍️ Which property is set to 20px in this rule?
li {
font-style: italic;
text-align: center;
font-weight: bold;
font-size: 20px;
} (a) 20px (b) font-size (c) text-align (d) background-color - 13.🎯 What kind of selector is .card? (a) an element selector (b) a class selector (c) an id selector
-
14.⚖️ What colour is the text of this element?
<h2 class="star" id="hero">Hi</h2>
CSS:
.star { color: blue; }
.star { color: green; } (a) yellow (b) orange (c) green (d) blue - 15.🔍 Which is the odd one out? (a) gives the page structure (b) makes headings and lists (c) makes a form box (d) counts down a timer
-
16.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 14px;
}
} - 17.🎨 One CSS file can style how many pages? (a) only one image (b) only one word (c) many pages (d) no pages
- 18.🖌️ Which CSS property sets the letter colour? (a) font-family (b) text-align (c) font-size (d) color
-
19.⚖️ What colour is the text of this element?
<p class="star" id="main">Hi</p>
CSS:
#main { color: red; }
#main { color: black; } (a) yellow (b) red (c) black (d) white - 20.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
-
21.✍️ What is the selector in this CSS rule?
.box {
margin: 10px;
padding: 8px;
font-size: 20px;
width: 300px;
} (a) h2 (b) .box (c) margin (d) 8px - 22.📱 min-width: 800px applies when the screen is ___. (a) exactly 100px (b) turned off (c) 800px or wider (d) 800px or narrower
-
23.🎯 Which CSS selector matches this element?
<p class="star" id="intro">Hello</p> (a) #main (b) .star (c) #star (d) .intro - 24.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) justify-content (c) display: flex (d) gap
-
25.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
width: 300px;
font-style: italic;
padding: 8px;
} - 26.What does justify-content: space-between do? (a) packs boxes at the end (b) equal gaps, none at ends (c) puts boxes in the middle (d) packs boxes at the start
- 27.🎯 What kind of selector is .menu? (a) an id selector (b) a class selector (c) an element selector
-
28.⚖️ What colour is the text of this element?
<p class="note" id="end">Hi</p>
CSS:
.note { color: red; }
.note { color: black; } (a) purple (b) red (c) blue (d) black -
29.✍️ Which property is set to 300px in this rule?
.note {
font-weight: bold;
width: 300px;
margin: 10px;
color: red;
} (a) 300px (b) font-style (c) color (d) width - 30.🎯 Which element does the selector .red style? (a) <div class="red"> (b) <div id="red"> (c) <span class="star"> (d) <div class="box">
-
31.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
border: 2px solid;
} - 32.🧩 Which language makes a link? (a) HTML (b) JavaScript (c) CSS
-
33.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 210px;
justify-content: flex-start;
}
Inside are 3 boxes, each 50px wide (no margins). -
34.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 20px;
}
} (a) No (b) Yes -
35.⚖️ What colour is the text of this element?
<p class="big" id="top">Hi</p>
CSS:
#top { color: white; }
#top { color: yellow; } (a) yellow (b) orange (c) white (d) blue - 36.🎯 What kind of selector is body? (a) an id selector (b) an element selector (c) a class selector
-
37.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 1024px) {
p {
font-size: 20px;
}
} (a) No (b) Yes - 38.Which of these is the content? (a) the gap round content (b) space inside the border (c) the gap to other boxes (d) the text or picture
-
39.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 50px;
padding: 15px;
border: 2px solid black;
margin: 5px;
} - 40.True or false: CSS counts down a timer. (a) True (b) False
Answer key
- li
- 244
- bright green
- the screen width
- 2
- 70
- No
- 16
- 170
- white
- 24
- font-size
- a class selector
- green
- counts down a timer
- 14
- many pages
- color
- black
- an id selector
- .box
- 800px or wider
- .star
- display: flex
- 3
- equal gaps, none at ends
- a class selector
- black
- width
- <div class="red">
- 1
- HTML
- 60
- Yes
- yellow
- an element selector
- Yes
- the text or picture
- 94
- False
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids