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.True or false: HTML changes the page live. (a) True (b) False
-
2.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 210px;
justify-content: flex-end;
}
Inside are 2 boxes, each 100px wide (no margins). - 3.🔍 Which is the odd one out? (a) lays out the page (b) reacts to a button click (c) sets colours and fonts (d) changes the text size
-
4.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 280px;
justify-content: flex-end;
}
Inside are 4 boxes, each 60px wide (no margins). -
5.✍️ Which property is set to 300px in this rule?
h1 {
width: 300px;
border: 2px solid;
color: red;
} (a) 300px (b) width (c) font-style (d) color -
6.🎯 Which CSS selector matches this element?
<h1 class="note" id="end">Hello</h1> (a) #note (b) h1 (c) h2 (d) .big - 7.🧩 Which language counts down a timer? (a) HTML (b) CSS (c) JavaScript
-
8.✍️ Which property is set to bold in this rule?
h1 {
font-weight: bold;
color: red;
} (a) width (b) border (c) font-weight (d) bold - 9.True or false: HTML reacts to a button click. (a) False (b) True
-
10.⚖️ What colour is the text of this element?
<p class="box" id="hero">Hi</p>
CSS:
.box { color: orange; }
.box { color: red; } (a) green (b) red (c) orange (d) black -
11.🖌️ What colour are the letters?
h2 {
background-color: red;
font-size: 12px;
color: white;
text-align: left;
} (a) blue (b) white (c) red -
12.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 30px;
}
} (a) No (b) Yes - 13.Which of these is the content? (a) space outside the border (b) a solid or dotted edge (c) the line round the box (d) the text or picture
- 14.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
- 15.✍️ Which sign goes between a property and its value? (a) ; (b) : (c) = (d) -
- 16.What does justify-content: space-between do? (a) packs boxes at the end (b) puts boxes in the middle (c) packs boxes at the start (d) equal gaps, none at ends
-
17.🖌️ Where does the text sit on its line?
h1 {
text-align: right;
color: purple;
font-size: 12px;
background-color: blue;
} (a) in the middle (b) on the left (c) on the right -
18.✍️ What is the selector in this CSS rule?
h2 {
width: 300px;
margin: 10px;
padding: 8px;
} (a) 10px (b) h1 (c) h2 (d) width -
19.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 110px;
padding: 15px;
border: 1px solid black;
margin: 5px;
} - 20.Which of these does HTML do? (a) checks a quiz answer (b) puts a picture on a page (c) reacts to a button click (d) rounds box corners
- 21.🎯 What kind of selector is #top? (a) a class selector (b) an element selector (c) an id selector
- 22.🔍 Which is the odd one out? (a) makes a form box (b) checks a quiz answer (c) reacts to a button click (d) changes the page live
-
23.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 220px;
justify-content: flex-start;
}
Inside are 2 boxes, each 100px wide (no margins). - 24.True or false: margin is the text or picture. (a) True (b) False
-
25.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
background-color: yellow;
} -
26.⚖️ What colour is the text of this element?
<h2 class="big" id="intro">Hi</h2>
CSS:
#intro { color: black; }
#intro { color: orange; } (a) orange (b) black (c) blue (d) yellow - 27.🌈 In #970000 the red part is the hex number 97. What is it as a normal number?
- 28.✍️ In color: blue; which part is the property? (a) color (b) ; (c) blue (d) :
- 29.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) turned off (c) 600px or narrower (d) exactly 1000px
-
30.🖌️ What colour is behind the letters?
p {
text-align: right;
background-color: yellow;
font-size: 32px;
color: purple;
} (a) yellow (b) green (c) purple - 31.What does justify-content: flex-start do? (a) equal gaps, none at ends (b) packs boxes at the end (c) packs boxes at the start (d) puts boxes in the middle
-
32.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 300px;
padding: 5px;
border: 4px solid black;
margin: 10px;
} -
33.🎯 Which CSS selector matches this element?
<h1 class="note" id="logo">Hello</h1> (a) .logo (b) #logo (c) h2 (d) .big -
34.⚖️ What colour is the text of this element?
<h2 class="menu" id="hero">Hi</h2>
CSS:
#hero { color: yellow; }
#hero { color: red; } (a) red (b) yellow (c) white (d) orange - 35.What does justify-content: center do? (a) packs boxes at the end (b) puts boxes in the middle (c) packs boxes at the start (d) equal gaps, none at ends
- 36.True or false: the border is the text or picture. (a) True (b) False
-
37.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 160px;
padding: 15px;
border: 5px solid black;
margin: 5px;
} - 38.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) neither (c) the shorter one (d) the first one
- 39.🖌️ Which CSS property colours behind the text? (a) background-color (b) text-align (c) font-family (d) font-size
-
40.🎯 Which CSS selector matches this element?
<li class="big" id="top">Hello</li> (a) .red (b) div (c) li (d) #big
Answer key
- False
- 10
- reacts to a button click
- 40
- width
- h1
- JavaScript
- font-weight
- False
- red
- white
- Yes
- the text or picture
- an element selector
- :
- equal gaps, none at ends
- on the right
- h2
- 152
- puts a picture on a page
- an id selector
- makes a form box
- 20
- False
- 1
- orange
- 151
- color
- 600px or narrower
- yellow
- packs boxes at the start
- 338
- #logo
- red
- puts boxes in the middle
- False
- 210
- the later one
- background-color
- li
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids