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.🎯 Which element does the selector #top style? (a) <p id="intro"> (b) <p id="top"> (c) <p class="top"> (d) <h1 class="red">
- 2.🖌️ Which CSS property makes letters bigger? (a) text-align (b) font-weight (c) background-color (d) font-size
-
3.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} -
4.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 480px) {
p {
font-size: 14px;
}
} - 5.🎨 Which tag connects an outside CSS file? (a) <link> (b) <a> (c) <img> (d) <css>
- 6.Which of these does CSS do? (a) rounds box corners (b) counts down a timer (c) puts a picture on a page (d) makes headings and lists
-
7.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 14px;
}
} -
8.🖌️ What colour are the letters?
h1 {
background-color: black;
color: green;
text-align: center;
font-size: 28px;
} (a) white (b) black (c) green - 9.🌈 Which colour is #ff00ff? (a) cyan (b) red (c) magenta (d) blue
- 10.🌈 Which colour is rgb(255, 255, 255)? (a) magenta (b) yellow (c) cyan (d) white
- 11.📦 In the box model, which part is the gap round content? (a) border (b) padding (c) content (d) margin
-
12.⚖️ What colour is the text of this element?
<h2 class="note" id="end">Hi</h2>
CSS:
#end { color: purple; }
h2 { color: orange; }
.note { color: black; } (a) purple (b) orange (c) blue (d) black -
13.✍️ How many declarations (property: value pairs) are in this rule?
p {
width: 300px;
} -
14.⚖️ What colour is the text of this element?
<h1 class="box" id="top">Hi</h1>
CSS:
#top { color: black; }
.box { color: green; }
h1 { color: orange; } (a) black (b) green (c) orange (d) blue -
15.✍️ What is the selector in this CSS rule?
.box {
width: 300px;
background-color: yellow;
} (a) yellow (b) width (c) .box (d) h2 - 16.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) turned off (c) 600px or narrower (d) exactly 1000px
- 17.🎨 A CSS file usually ends with which extension? (a) .png (b) .html (c) .js (d) .css
-
18.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 120px;
padding: 5px;
border: 4px solid black;
margin: 15px;
} - 19.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the first one (c) the later one (d) neither
-
20.⚖️ What colour is the text of this element?
<p class="note" id="end">Hi</p>
CSS:
#end { color: yellow; }
.note { color: blue; } (a) yellow (b) purple (c) orange (d) blue - 21.What does justify-content: space-between do? (a) packs boxes at the start (b) equal gaps, none at ends (c) puts boxes in the middle (d) packs boxes at the end
-
22.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 90px;
padding: 15px;
border: 1px solid black;
margin: 15px;
} -
23.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 18px;
}
} - 24.True or false: HTML makes a link. (a) False (b) True
- 25.💪 Which flexbox property spaces boxes along a row? (a) gap (b) align-items (c) display: flex (d) justify-content
- 26.🌈 Which colour is #ff0000? (a) magenta (b) cyan (c) black (d) red
-
27.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
text-align: center;
color: red;
width: 300px;
margin: 10px;
} - 28.💪 Which justify-content value packs boxes at the start? (a) space-between (b) center (c) flex-start (d) flex-end
-
29.⚖️ What colour is the text of this element?
<p class="big" id="end">Hi</p>
CSS:
p { color: black; }
.big { color: blue; } (a) green (b) blue (c) black (d) yellow -
30.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 210px;
padding: 20px;
border: 2px solid black;
margin: 5px;
} - 31.✍️ In color: blue; which part is the value? (a) : (b) color (c) ; (d) blue
-
32.🖌️ What colour are the letters?
li {
background-color: green;
font-size: 12px;
text-align: left;
color: white;
} (a) green (b) white (c) purple - 33.🧩 Which language makes a form box? (a) HTML (b) JavaScript (c) CSS
-
34.✍️ How many declarations (property: value pairs) are in this rule?
li {
text-align: center;
padding: 8px;
border: 2px solid;
font-size: 20px;
} -
35.🎯 Which CSS selector matches this element?
<h1 class="note" id="hero">Hello</h1> (a) .big (b) .hero (c) #note (d) #hero - 36.📱 What does a media query check? (a) the screen width (b) the time of day (c) the page title (d) the battery level
- 37.🎯 What kind of selector is img? (a) an id selector (b) a class selector (c) an element selector
- 38.🧩 Which language makes headings and lists? (a) JavaScript (b) HTML (c) CSS
- 39.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
-
40.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 110px;
justify-content: flex-end;
}
Inside are 2 boxes, each 40px wide (no margins).
Answer key
- <p id="top">
- font-size
- 20
- 14
- <link>
- rounds box corners
- 14
- green
- magenta
- white
- padding
- purple
- 1
- black
- .box
- 600px or narrower
- .css
- 168
- the later one
- yellow
- equal gaps, none at ends
- 122
- 18
- True
- justify-content
- red
- 4
- flex-start
- blue
- 264
- blue
- white
- HTML
- 4
- #hero
- the screen width
- an element selector
- HTML
- an id selector
- 30
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids