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 much empty space (px) is left after the last box?
.row {
display: flex;
width: 240px;
justify-content: flex-start;
}
Inside are 4 boxes, each 50px wide (no margins). - 2.🧩 Which language puts a picture on a page? (a) HTML (b) CSS (c) JavaScript
-
3.⚖️ What colour is the text of this element?
<h2 class="red" id="logo">Hi</h2>
CSS:
#logo { color: green; }
#logo { color: red; } (a) yellow (b) purple (c) green (d) red -
4.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 320px;
justify-content: center;
}
Inside are 4 boxes, each 50px wide (no margins). -
5.✍️ Which property is set to red in this rule?
p {
font-size: 20px;
text-align: center;
color: red;
} (a) font-size (b) color (c) text-align (d) red - 6.💪 Which justify-content value packs boxes at the end? (a) flex-start (b) flex-end (c) space-between (d) center
- 7.True or false: HTML rounds box corners. (a) False (b) True
- 8.✍️ How does a CSS comment start? (a) // (b) <!-- (c) # (d) /*
-
9.✍️ What is the selector in this CSS rule?
h2 {
font-weight: bold;
font-size: 20px;
} (a) font-weight (b) h2 (c) h1 (d) 20px - 10.True or false: the content is space outside the border. (a) True (b) False
- 11.💪 Which justify-content value packs boxes at the start? (a) flex-end (b) flex-start (c) center (d) space-between
- 12.Which of these does JavaScript do? (a) changes the text size (b) rounds box corners (c) reacts to a button click (d) makes a link
- 13.🎯 Can many elements share the same class? (a) Yes (b) No
-
14.⚖️ What colour is the text of this element?
<h2 class="star" id="end">Hi</h2>
CSS:
h2 { color: blue; }
#end { color: purple; } (a) black (b) blue (c) purple (d) yellow -
15.✍️ What value is given to font-size in this rule?
h1 {
text-align: center;
width: 300px;
padding: 8px;
font-size: 20px;
} (a) center (b) font-size (c) 20px (d) yellow - 16.What does justify-content: center do? (a) puts boxes in the middle (b) equal gaps, none at ends (c) packs boxes at the start (d) packs boxes at the end
- 17.🌈 In #rrggbb, which colour do the first two digits give? (a) blue (b) red (c) green (d) black
-
18.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 440px;
justify-content: center;
}
Inside are 4 boxes, each 100px wide (no margins). - 19.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the later one (c) the first one (d) neither
- 20.🎯 What kind of selector is p? (a) an element selector (b) an id selector (c) a class selector
- 21.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
- 22.🎯 What kind of selector is #top? (a) an element selector (b) an id selector (c) a class selector
- 23.🎯 What kind of selector is #end? (a) an id selector (b) a class selector (c) an element selector
- 24.🎨 Which tag holds CSS inside the head? (a) <css> (b) <script> (c) <style> (d) <body>
-
25.🖌️ What colour are the letters?
h1 {
text-align: right;
font-size: 28px;
color: green;
background-color: purple;
} (a) green (b) purple (c) blue -
26.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 32px;
}
} -
27.✍️ What value is given to background-color in this rule?
h1 {
background-color: yellow;
border: 2px solid;
} (a) background-color (b) 10px (c) 8px (d) yellow -
28.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
padding: 8px;
} - 29.📦 In the box model, which part is the text or picture? (a) margin (b) border (c) padding (d) content
-
30.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 100px;
justify-content: flex-end;
}
Inside are 2 boxes, each 40px wide (no margins). - 31.What does background-color do? (a) makes letters bigger (b) centres a heading (c) colours behind the text (d) sets the letter colour
- 32.🖌️ Which CSS property colours behind the text? (a) font-weight (b) font-family (c) color (d) background-color
-
33.🖌️ Where does the text sit on its line?
p {
background-color: yellow;
font-size: 28px;
color: red;
text-align: left;
} (a) on the left (b) on the right (c) in the middle -
34.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 180px;
justify-content: flex-end;
}
Inside are 2 boxes, each 60px wide (no margins). -
35.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 120px;
justify-content: flex-start;
}
Inside are 2 boxes, each 50px wide (no margins). - 36.✍️ Which sign goes between a property and its value? (a) = (b) - (c) ; (d) :
- 37.🎯 What kind of selector is #logo? (a) an element selector (b) a class selector (c) an id selector
- 38.True or false: CSS changes the page live. (a) False (b) True
-
39.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 1024px) {
p {
font-size: 22px;
}
} -
40.✍️ What is the selector in this CSS rule?
h2 {
border: 2px solid;
font-style: italic;
margin: 10px;
} (a) h2 (b) border (c) italic (d) h1
Answer key
- 40
- HTML
- red
- 60
- color
- flex-end
- False
- /*
- h2
- False
- flex-start
- reacts to a button click
- Yes
- purple
- 20px
- puts boxes in the middle
- red
- 20
- the later one
- an element selector
- an element selector
- an id selector
- an id selector
- <style>
- green
- 24
- yellow
- 1
- content
- 20
- colours behind the text
- background-color
- on the left
- 60
- 20
- :
- an id selector
- False
- 22
- h2
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids