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.🌈 In #00000e the blue part is the hex number 0e. What is it as a normal number?
- 2.🎨 Which attribute adds CSS inside one tag? (a) href (b) style (c) alt (d) src
- 3.🌈 Which colour is rgb(255, 255, 255)? (a) white (b) red (c) black (d) magenta
-
4.✍️ What is the selector in this CSS rule?
h2 {
text-align: center;
padding: 8px;
} (a) text-align (b) 8px (c) h1 (d) h2 -
5.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
font-style: italic;
width: 300px;
text-align: center;
} - 6.What does text-align do? (a) makes letters bigger (b) colours behind the text (c) sets the letter colour (d) centres a heading
-
7.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 160px;
padding: 30px;
border: 4px solid black;
margin: 15px;
} - 8.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
-
9.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 230px;
padding: 20px;
border: 5px solid black;
margin: 20px;
} - 10.🎯 Which element does the selector #logo style? (a) <span id="end"> (b) <span class="logo"> (c) <span id="logo"> (d) <p class="note">
- 11.🧩 Which language adds space around boxes? (a) CSS (b) JavaScript (c) HTML
-
12.🖌️ Where does the text sit on its line?
li {
color: blue;
font-size: 32px;
text-align: left;
background-color: orange;
} (a) in the middle (b) on the left (c) on the right -
13.🖌️ How big is the text, in px?
p {
background-color: blue;
font-size: 20px;
text-align: left;
color: white;
} - 14.Which of these does HTML do? (a) changes the text size (b) adds space around boxes (c) puts a picture on a page (d) reacts to a button click
-
15.✍️ Which property is set to 300px in this rule?
h1 {
font-size: 20px;
color: red;
border: 2px solid;
width: 300px;
} (a) 300px (b) font-style (c) color (d) width -
16.⚖️ What colour is the text of this element?
<p class="red" id="logo">Hi</p>
CSS:
.red { color: purple; }
#logo { color: yellow; } (a) black (b) yellow (c) purple (d) orange - 17.💪 Which flexbox property lines boxes up across? (a) align-items (b) justify-content (c) flex-direction (d) gap
-
18.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 400px;
justify-content: center;
}
Inside are 3 boxes, each 80px wide (no margins). -
19.⚖️ What colour is the text of this element?
<h2 class="red" id="intro">Hi</h2>
CSS:
.red { color: green; }
.red { color: purple; } (a) orange (b) purple (c) green (d) blue - 20.🧩 Which language shows a pop-up message? (a) HTML (b) CSS (c) JavaScript
-
21.✍️ What value is given to width in this rule?
body {
background-color: yellow;
width: 300px;
font-size: 20px;
} (a) italic (b) width (c) red (d) 300px -
22.🎯 Which CSS selector matches this element?
<p class="box" id="end">Hello</p> (a) #box (b) .end (c) #hero (d) .box -
23.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 210px;
justify-content: flex-start;
}
Inside are 2 boxes, each 80px wide (no margins). -
24.✍️ How many declarations (property: value pairs) are in this rule?
.box {
background-color: yellow;
text-align: center;
} - 25.What does justify-content: space-between do? (a) puts boxes in the middle (b) packs boxes at the start (c) equal gaps, none at ends (d) packs boxes at the end
- 26.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the hr tag (c) the br tag (d) the viewport meta tag
-
27.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 450px;
justify-content: flex-start;
}
Inside are 4 boxes, each 100px wide (no margins). - 28.What does justify-content: center do? (a) packs boxes at the start (b) packs boxes at the end (c) equal gaps, none at ends (d) puts boxes in the middle
-
29.✍️ What is the selector in this CSS rule?
.box {
color: red;
background-color: yellow;
width: 300px;
} (a) h2 (b) color (c) .box (d) yellow -
30.✍️ Which property is set to 20px in this rule?
.note {
font-size: 20px;
margin: 10px;
background-color: yellow;
width: 300px;
} (a) text-align (b) 20px (c) font-size (d) background-color -
31.🎯 Which CSS selector matches this element?
<h2 class="menu" id="intro">Hello</h2> (a) .note (b) li (c) .menu (d) .intro -
32.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 270px;
padding: 20px;
border: 5px solid black;
margin: 20px;
} -
33.✍️ Which property is set to italic in this rule?
.box {
width: 300px;
font-style: italic;
padding: 8px;
} (a) italic (b) color (c) font-size (d) font-style -
34.⚖️ What colour is the text of this element?
<h2 class="box" id="main">Hi</h2>
CSS:
#main { color: purple; }
#main { color: yellow; } (a) yellow (b) purple (c) white (d) blue -
35.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 190px;
padding: 10px;
border: 2px solid black;
margin: 0px;
} -
36.⚖️ What colour is the text of this element?
<h1 class="box" id="top">Hi</h1>
CSS:
#top { color: black; }
#top { color: purple; } (a) green (b) black (c) yellow (d) purple - 37.🔍 Which is the odd one out? (a) adds space around boxes (b) changes the page live (c) checks a quiz answer (d) shows a pop-up message
- 38.💪 Which justify-content value packs boxes at the start? (a) center (b) space-between (c) flex-start (d) flex-end
-
39.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 200px;
justify-content: center;
}
Inside are 2 boxes, each 60px wide (no margins). - 40.🧩 Which language makes a link? (a) JavaScript (b) CSS (c) HTML
Answer key
- 14
- style
- white
- h2
- 3
- centres a heading
- 258
- an id selector
- 320
- <span id="logo">
- CSS
- on the left
- 20
- puts a picture on a page
- width
- yellow
- align-items
- 80
- purple
- JavaScript
- 300px
- .box
- 50
- 2
- equal gaps, none at ends
- the viewport meta tag
- 50
- puts boxes in the middle
- .box
- font-size
- .menu
- 320
- font-style
- yellow
- 214
- purple
- adds space around boxes
- flex-start
- 40
- HTML
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids