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.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 1024px) {
p {
font-size: 18px;
}
} (a) No (b) Yes -
2.✍️ How many declarations (property: value pairs) are in this rule?
.box {
background-color: yellow;
} -
3.⚖️ What colour is the text of this element?
<h2 class="big" id="main">Hi</h2>
CSS:
#main { color: yellow; }
.big { color: black; }
h2 { color: blue; } (a) yellow (b) red (c) blue (d) black -
4.🖌️ How big is the text, in px?
h1 {
font-size: 28px;
background-color: green;
color: blue;
text-align: right;
} - 5.💪 Which justify-content value packs boxes at the end? (a) flex-end (b) flex-start (c) space-between (d) center
-
6.🖌️ Where does the text sit on its line?
h1 {
text-align: left;
font-size: 40px;
background-color: black;
color: orange;
} (a) on the right (b) on the left (c) in the middle - 7.💪 Which flexbox property lines boxes up across? (a) align-items (b) display: flex (c) gap (d) justify-content
- 8.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
- 9.🎨 Which attribute adds CSS inside one tag? (a) alt (b) style (c) src (d) href
-
10.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 60px;
padding: 10px;
border: 1px solid black;
margin: 20px;
} -
11.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 10px;
}
} - 12.💪 Which flexbox property sets space between boxes? (a) flex-direction (b) gap (c) display: flex (d) align-items
-
13.⚖️ What colour is the text of this element?
<h1 class="red" id="top">Hi</h1>
CSS:
#top { color: black; }
#top { color: blue; } (a) white (b) black (c) green (d) blue -
14.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 14px;
}
} -
15.🎯 Which CSS selector matches this element?
<li class="star" id="intro">Hello</li> (a) .menu (b) #star (c) div (d) li - 16.What does justify-content: flex-start do? (a) packs boxes at the start (b) packs boxes at the end (c) puts boxes in the middle (d) equal gaps, none at ends
- 17.✍️ In color: blue; which part is the value? (a) : (b) color (c) ; (d) blue
- 18.🔍 Which is the odd one out? (a) counts down a timer (b) shows a pop-up message (c) reacts to a button click (d) changes the text size
- 19.Which of these does HTML do? (a) adds space around boxes (b) lays out the page (c) shows a pop-up message (d) makes a link
-
20.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 80px;
padding: 20px;
border: 5px solid black;
margin: 0px;
} - 21.Which of these does HTML do? (a) reacts to a button click (b) changes the page live (c) makes a form box (d) lays out the page
- 22.🔍 Which is the odd one out? (a) reacts to a button click (b) puts a picture on a page (c) gives the page structure (d) makes a link
- 23.🎨 Which tag connects an outside CSS file? (a) <link> (b) <css> (c) <a> (d) <img>
-
24.🖌️ How big is the text, in px?
p {
color: orange;
text-align: left;
background-color: blue;
font-size: 32px;
} - 25.True or false: CSS sets colours and fonts. (a) False (b) True
-
26.⚖️ What colour is the text of this element?
<p class="box" id="logo">Hi</p>
CSS:
#logo { color: white; }
p { color: orange; } (a) white (b) purple (c) orange (d) red - 27.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
- 28.💪 Which justify-content value puts boxes in the middle? (a) flex-end (b) center (c) flex-start (d) space-between
-
29.✍️ Which property is set to 10px in this rule?
p {
width: 300px;
border: 2px solid;
padding: 8px;
margin: 10px;
} (a) padding (b) 10px (c) font-weight (d) margin -
30.✍️ How many declarations (property: value pairs) are in this rule?
.box {
color: red;
padding: 8px;
} -
31.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 230px;
padding: 15px;
border: 1px solid black;
margin: 15px;
} -
32.✍️ How many declarations (property: value pairs) are in this rule?
li {
width: 300px;
} - 33.🖌️ Which CSS property sets the letter colour? (a) background-color (b) text-align (c) font-size (d) color
-
34.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 1024px) {
p {
font-size: 22px;
}
} (a) Yes (b) No -
35.✍️ What is the selector in this CSS rule?
li {
color: red;
font-style: italic;
font-size: 20px;
} (a) li (b) color (c) italic (d) body - 36.🖌️ Which CSS property picks the font style? (a) font-family (b) color (c) font-size (d) font-weight
- 37.🎨 One CSS file can style how many pages? (a) only one image (b) only one word (c) no pages (d) many pages
- 38.💪 Which justify-content value equal gaps, none at ends? (a) flex-end (b) center (c) space-between (d) flex-start
-
39.⚖️ What colour is the text of this element?
<p class="big" id="top">Hi</p>
CSS:
.big { color: green; }
.big { color: white; } (a) purple (b) white (c) green (d) orange - 40.🌈 Which colour is #ff00ff? (a) magenta (b) blue (c) white (d) bright green
Answer key
- Yes
- 1
- yellow
- 28
- flex-end
- on the left
- align-items
- equal gaps, none at ends
- style
- 122
- 10
- gap
- blue
- 14
- li
- packs boxes at the start
- blue
- changes the text size
- makes a link
- 130
- makes a form box
- reacts to a button click
- <link>
- 32
- True
- white
- an element selector
- center
- margin
- 2
- 262
- 1
- color
- No
- li
- font-family
- many pages
- space-between
- white
- magenta
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids