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.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 280px;
padding: 30px;
border: 2px solid black;
margin: 5px;
} - 2.✍️ CSS declarations go inside which brackets? (a) ( ) (b) [ ] (c) < > (d) { }
-
3.⚖️ What colour is the text of this element?
<h1 class="box" id="end">Hi</h1>
CSS:
h1 { color: yellow; }
h1 { color: blue; } (a) black (b) blue (c) white (d) yellow -
4.🖌️ What colour are the letters?
li {
font-size: 20px;
background-color: white;
text-align: left;
color: orange;
} (a) yellow (b) white (c) orange - 5.🖌️ Which CSS property centres a heading? (a) background-color (b) font-weight (c) text-align (d) font-size
- 6.🌈 Which hex code is bright green? (a) #00ffff (b) #00ff00 (c) #ffff00 (d) #ff0000
- 7.🌈 Which colour of light is strongest in rgb(105, 160, 59)? (a) green (b) red (c) blue
-
8.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 140px;
justify-content: center;
}
Inside are 2 boxes, each 60px wide (no margins). - 9.📦 In the box model, which part is space inside the border? (a) padding (b) margin (c) border (d) content
-
10.⚖️ What colour is the text of this element?
<p class="note" id="hero">Hi</p>
CSS:
p { color: orange; }
p { color: yellow; } (a) orange (b) red (c) yellow (d) purple - 11.🎨 Which attribute adds CSS inside one tag? (a) src (b) style (c) alt (d) href
-
12.✍️ Which property is set to 20px in this rule?
h2 {
padding: 8px;
font-style: italic;
font-size: 20px;
} (a) 20px (b) text-align (c) background-color (d) font-size -
13.🎯 Which CSS selector matches this element?
<li class="red" id="end">Hello</li> (a) .box (b) #hero (c) #end (d) .end -
14.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 190px;
padding: 5px;
border: 3px solid black;
margin: 5px;
} -
15.✍️ What is the selector in this CSS rule?
h1 {
font-size: 20px;
width: 300px;
} (a) 300px (b) h1 (c) p (d) font-size - 16.💪 Which flexbox property turns on flexbox? (a) display: flex (b) flex-direction (c) align-items (d) gap
-
17.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 80px;
padding: 5px;
border: 5px solid black;
margin: 10px;
} -
18.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 20px;
}
} (a) No (b) Yes - 19.🌈 Which hex code is magenta? (a) #00ff00 (b) #ff00ff (c) #ffff00 (d) #ff0000
-
20.⚖️ What colour is the text of this element?
<h1 class="star" id="end">Hi</h1>
CSS:
.star { color: black; }
.star { color: purple; } (a) black (b) yellow (c) purple (d) orange - 21.True or false: the border is the line round the box. (a) False (b) True
-
22.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 180px;
justify-content: flex-start;
}
Inside are 2 boxes, each 80px wide (no margins). - 23.🔍 Which is the odd one out? (a) makes headings and lists (b) puts a picture on a page (c) makes a form box (d) shows a pop-up message
-
24.⚖️ What colour is the text of this element?
<h2 class="menu" id="main">Hi</h2>
CSS:
h2 { color: red; }
#main { color: blue; } (a) blue (b) white (c) yellow (d) red - 25.What does font-size do? (a) centres a heading (b) makes letters bigger (c) picks the font style (d) sets the letter colour
-
26.🖌️ What colour are the letters?
h1 {
background-color: orange;
font-size: 16px;
text-align: center;
color: yellow;
} (a) white (b) orange (c) yellow - 27.🌈 Which hex code is red? (a) #ffffff (b) #0000ff (c) #ffff00 (d) #ff0000
-
28.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 280px;
justify-content: center;
}
Inside are 3 boxes, each 80px wide (no margins). -
29.✍️ Which property is set to 300px in this rule?
#top {
width: 300px;
text-align: center;
} (a) 300px (b) width (c) font-style (d) color -
30.🖌️ What colour is behind the letters?
h1 {
background-color: black;
font-size: 20px;
text-align: right;
color: purple;
} (a) white (b) black (c) purple -
31.✍️ Which property is set to yellow in this rule?
li {
margin: 10px;
background-color: yellow;
} (a) background-color (b) yellow (c) padding (d) margin -
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: 220px;
padding: 25px;
border: 5px solid black;
margin: 15px;
} -
33.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 100px;
padding: 20px;
border: 3px solid black;
margin: 0px;
} -
34.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 230px;
justify-content: flex-start;
}
Inside are 3 boxes, each 60px wide (no margins). - 35.Which of these does JavaScript do? (a) lays out the page (b) makes headings and lists (c) shows a pop-up message (d) puts a picture on a page
-
36.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 20px;
}
} (a) Yes (b) No - 37.🎯 How many elements on a page should have the same id? (a) 5 (b) any number (c) 1 (d) 2
-
38.✍️ Which property is set to center in this rule?
li {
margin: 10px;
text-align: center;
} (a) text-align (b) background-color (c) center (d) margin -
39.✍️ What is the selector in this CSS rule?
#top {
background-color: yellow;
width: 300px;
font-size: 20px;
border: 2px solid;
} (a) background-color (b) 300px (c) li (d) #top - 40.True or false: JavaScript lays out the page. (a) False (b) True
Answer key
- 344
- { }
- blue
- orange
- text-align
- #00ff00
- green
- 10
- padding
- yellow
- style
- font-size
- #end
- 206
- h1
- display: flex
- 100
- No
- #ff00ff
- purple
- True
- 20
- shows a pop-up message
- blue
- makes letters bigger
- yellow
- #ff0000
- 20
- width
- black
- background-color
- 280
- 146
- 50
- shows a pop-up message
- No
- 1
- text-align
- #top
- False
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids