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 CSS selector matches this element?
<h2 class="box" id="intro">Hello</h2> (a) #main (b) #box (c) li (d) h2 -
2.✍️ Which property is set to 8px in this rule?
h1 {
width: 300px;
text-align: center;
padding: 8px;
} (a) font-weight (b) 8px (c) padding (d) border - 3.True or false: li is an id selector. (a) False (b) True
-
4.✍️ What is the selector in this CSS rule?
body {
text-align: center;
margin: 10px;
padding: 8px;
} (a) text-align (b) .box (c) 10px (d) body -
5.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 150px;
padding: 5px;
border: 1px solid black;
margin: 0px;
} - 6.💪 Which justify-content value equal gaps, none at ends? (a) flex-end (b) center (c) space-between (d) flex-start
- 7.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) 800px or wider (c) 800px or narrower (d) exactly 100px
- 8.🌈 What is the biggest number one colour can have in rgb()? (a) 1000 (b) 100 (c) 99 (d) 255
-
9.🎯 Which CSS selector matches this element?
<p class="red" id="top">Hello</p> (a) #top (b) #red (c) .top (d) .box - 10.🌈 Which colour of light is strongest in rgb(61, 251, 7)? (a) blue (b) red (c) green
-
11.🖌️ What colour are the letters?
li {
text-align: left;
background-color: white;
color: purple;
font-size: 16px;
} (a) green (b) white (c) purple - 12.🧩 Which language rounds box corners? (a) JavaScript (b) HTML (c) CSS
-
13.⚖️ What colour is the text of this element?
<h2 class="box" id="hero">Hi</h2>
CSS:
h2 { color: red; }
h2 { color: purple; } (a) white (b) yellow (c) purple (d) red - 14.True or false: #logo is an id selector. (a) True (b) False
-
15.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 200px;
justify-content: flex-end;
}
Inside are 3 boxes, each 60px wide (no margins). - 16.📱 Responsive design means a page ___. (a) has no pictures (b) is only for laptops (c) fits every screen (d) never changes
-
17.⚖️ What colour is the text of this element?
<h1 class="menu" id="main">Hi</h1>
CSS:
h1 { color: green; }
h1 { color: purple; } (a) blue (b) purple (c) black (d) green - 18.🧩 Which language adds space around boxes? (a) HTML (b) JavaScript (c) CSS
- 19.💪 Which flexbox property lines boxes up across? (a) gap (b) flex-direction (c) justify-content (d) align-items
- 20.💪 Which justify-content value packs boxes at the start? (a) space-between (b) flex-end (c) center (d) flex-start
- 21.True or false: .card is an element selector. (a) True (b) False
- 22.What does font-size do? (a) picks the font style (b) colours behind the text (c) makes letters bigger (d) centres a heading
-
23.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 270px;
justify-content: flex-start;
}
Inside are 4 boxes, each 50px wide (no margins). -
24.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 190px;
padding: 20px;
border: 2px solid black;
margin: 10px;
} - 25.Which of these does HTML do? (a) adds space around boxes (b) sets colours and fonts (c) changes the page live (d) makes headings and lists
- 26.True or false: CSS puts a picture on a page. (a) True (b) False
-
27.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 210px;
padding: 10px;
border: 4px solid black;
margin: 0px;
} - 28.🌈 In #rrggbb, which colour do the first two digits give? (a) red (b) black (c) blue (d) green
- 29.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
- 30.📦 In the box model, which part is space outside the border? (a) margin (b) content (c) border (d) padding
-
31.🖌️ Where does the text sit on its line?
li {
background-color: black;
text-align: right;
font-size: 12px;
color: yellow;
} (a) on the left (b) on the right (c) in the middle - 32.True or false: the content is space outside the border. (a) False (b) True
- 33.🌈 Which colour is #ffff00? (a) yellow (b) black (c) blue (d) bright green
- 34.🌈 Which colour is rgb(0, 255, 0)? (a) bright green (b) white (c) blue (d) red
-
35.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 16px;
}
} - 36.📦 In the box model, which part is the line round the box? (a) content (b) padding (c) margin (d) border
- 37.🌈 Which colour of light is strongest in rgb(204, 77, 48)? (a) green (b) blue (c) red
- 38.✍️ Which sign ends each CSS declaration? (a) : (b) , (c) ; (d) .
-
39.🖌️ What colour are the letters?
li {
background-color: black;
font-size: 32px;
text-align: center;
color: yellow;
} (a) black (b) blue (c) yellow - 40.🌈 In #530000 the red part is the hex number 53. What is it as a normal number?
Answer key
- h2
- padding
- False
- body
- 162
- space-between
- 800px or wider
- 255
- #top
- green
- purple
- CSS
- purple
- True
- 20
- fits every screen
- purple
- CSS
- align-items
- flex-start
- False
- makes letters bigger
- 70
- 254
- makes headings and lists
- False
- 238
- red
- packs boxes at the start
- margin
- on the right
- False
- yellow
- bright green
- 16
- border
- red
- ;
- yellow
- 83
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids