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 selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
- 2.🔍 Which is the odd one out? (a) lays out the page (b) changes the text size (c) changes the page live (d) sets colours and fonts
- 3.🌈 In #rrggbb, which colour do the last two digits give? (a) white (b) blue (c) red (d) green
-
4.🎯 Which CSS selector matches this element?
<h1 class="note" id="end">Hello</h1> (a) h2 (b) .big (c) .end (d) #end -
5.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 240px;
justify-content: flex-end;
}
Inside are 4 boxes, each 40px wide (no margins). -
6.🎯 Which CSS selector matches this element?
<h2 class="box" id="logo">Hello</h2> (a) li (b) .box (c) .logo (d) .star - 7.🎨 Which tag connects an outside CSS file? (a) <img> (b) <css> (c) <link> (d) <a>
-
8.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 1024px) {
p {
font-size: 24px;
}
} (a) No (b) Yes - 9.📦 In the box model, which part is the gap round content? (a) border (b) content (c) padding (d) margin
- 10.What does font-family do? (a) sets the letter colour (b) colours behind the text (c) makes letters bigger (d) picks the font style
- 11.💪 Which flexbox property sets space between boxes? (a) flex-direction (b) align-items (c) display: flex (d) gap
- 12.🧩 Which language shows a pop-up message? (a) JavaScript (b) CSS (c) HTML
-
13.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 480px) {
p {
font-size: 14px;
}
} - 14.✍️ In color: blue; which part is the value? (a) : (b) blue (c) color (d) ;
- 15.✍️ Which sign goes between a property and its value? (a) - (b) ; (c) = (d) :
-
16.✍️ What is the selector in this CSS rule?
h2 {
font-weight: bold;
text-align: center;
background-color: yellow;
} (a) h1 (b) center (c) font-weight (d) h2 -
17.🖌️ Where does the text sit on its line?
li {
background-color: purple;
font-size: 36px;
color: yellow;
text-align: left;
} (a) on the left (b) in the middle (c) on the right - 18.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) 800px or narrower (c) 800px or wider (d) exactly 100px
-
19.✍️ Which property is set to 20px in this rule?
.note {
text-align: center;
color: red;
font-weight: bold;
font-size: 20px;
} (a) 20px (b) font-size (c) background-color (d) text-align -
20.⚖️ What colour is the text of this element?
<h1 class="box" id="logo">Hi</h1>
CSS:
.box { color: blue; }
.box { color: purple; } (a) blue (b) green (c) yellow (d) purple -
21.🖌️ What colour are the letters?
h1 {
background-color: orange;
text-align: left;
color: green;
font-size: 28px;
} (a) orange (b) green (c) blue -
22.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 180px;
justify-content: flex-end;
}
Inside are 2 boxes, each 50px wide (no margins). - 23.🖌️ Which CSS property centres a heading? (a) font-weight (b) font-size (c) text-align (d) color
-
24.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 280px;
justify-content: flex-start;
}
Inside are 3 boxes, each 80px wide (no margins). -
25.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 190px;
justify-content: flex-start;
}
Inside are 4 boxes, each 40px wide (no margins). - 26.🎨 Which attribute adds CSS inside one tag? (a) src (b) href (c) style (d) alt
- 27.✍️ How does a CSS comment start? (a) // (b) <!-- (c) # (d) /*
- 28.📦 In the box model, which part is the line round the box? (a) margin (b) padding (c) border (d) content
-
29.🖌️ What colour is behind the letters?
li {
text-align: center;
color: white;
font-size: 32px;
background-color: green;
} (a) green (b) orange (c) white - 30.🎯 Which element does the selector .big style? (a) <p class="box"> (b) <span id="big"> (c) <span class="big"> (d) <span class="red">
- 31.🖌️ Which CSS property makes letters bigger? (a) color (b) text-align (c) font-size (d) background-color
-
32.🎯 Which CSS selector matches this element?
<span class="star" id="end">Hello</span> (a) #end (b) .menu (c) #star (d) p - 33.🧩 Which language changes the page live? (a) CSS (b) JavaScript (c) HTML
-
34.⚖️ What colour is the text of this element?
<p class="note" id="main">Hi</p>
CSS:
p { color: green; }
#main { color: purple; }
.note { color: yellow; } (a) green (b) orange (c) yellow (d) purple -
35.✍️ What value is given to font-weight in this rule?
#top {
color: red;
font-weight: bold;
text-align: center;
} (a) 2px solid (b) bold (c) font-weight (d) 300px -
36.🖌️ What colour are the letters?
h1 {
text-align: center;
color: black;
background-color: white;
font-size: 36px;
} (a) green (b) white (c) black -
37.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 1024px) {
p {
font-size: 32px;
}
} (a) Yes (b) No -
38.⚖️ What colour is the text of this element?
<p class="menu" id="end">Hi</p>
CSS:
p { color: blue; }
p { color: yellow; } (a) black (b) orange (c) blue (d) yellow - 39.✍️ In color: blue; which part is the property? (a) ; (b) : (c) color (d) blue
-
40.🖌️ How big is the text, in px?
li {
text-align: right;
color: green;
font-size: 16px;
background-color: blue;
}
Answer key
- an element selector
- changes the page live
- blue
- #end
- 80
- .box
- <link>
- No
- padding
- picks the font style
- gap
- JavaScript
- 16
- blue
- :
- h2
- on the left
- 800px or wider
- font-size
- purple
- green
- 80
- text-align
- 40
- 30
- style
- /*
- border
- green
- <span class="big">
- font-size
- #end
- JavaScript
- purple
- bold
- black
- No
- yellow
- color
- 16
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids