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.🎯 What kind of selector is .menu? (a) a class selector (b) an id selector (c) an element selector
-
2.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 190px;
padding: 25px;
border: 4px solid black;
margin: 10px;
} - 3.🎯 Which element does the selector h2 style? (a) <span id="hero"> (b) <div class="menu"> (c) <h2 class="menu"> (d) <li>
- 4.✍️ CSS declarations go inside which brackets? (a) [ ] (b) < > (c) { } (d) ( )
-
5.⚖️ What colour is the text of this element?
<h1 class="note" id="main">Hi</h1>
CSS:
.note { color: yellow; }
h1 { color: purple; }
#main { color: red; } (a) purple (b) black (c) yellow (d) red -
6.🖌️ What colour is behind the letters?
h1 {
font-size: 28px;
background-color: blue;
text-align: right;
color: yellow;
} (a) blue (b) purple (c) yellow - 7.💪 Which flexbox property lines boxes up across? (a) gap (b) justify-content (c) align-items (d) flex-direction
- 8.True or false: HTML changes the text size. (a) False (b) True
- 9.✍️ Which sign goes between a property and its value? (a) - (b) = (c) ; (d) :
-
10.🖌️ What colour are the letters?
p {
font-size: 12px;
background-color: green;
color: blue;
text-align: center;
} (a) green (b) red (c) blue - 11.Which of these does CSS do? (a) makes a form box (b) puts a picture on a page (c) makes headings and lists (d) sets colours and fonts
-
12.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 200px;
justify-content: center;
}
Inside are 4 boxes, each 40px wide (no margins). - 13.Which of these does HTML do? (a) makes headings and lists (b) adds space around boxes (c) reacts to a button click (d) rounds box corners
- 14.🌈 Which colour is rgb(0, 255, 0)? (a) yellow (b) cyan (c) bright green (d) blue
- 15.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) red (c) blue (d) white
- 16.⚖️ Which selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
-
17.🎯 Which CSS selector matches this element?
<span class="menu" id="end">Hello</span> (a) #menu (b) span (c) .end (d) #hero - 18.Which of these does HTML do? (a) makes a form box (b) checks a quiz answer (c) changes the page live (d) shows a pop-up message
-
19.🎯 Which CSS selector matches this element?
<p class="box" id="end">Hello</p> (a) .end (b) #hero (c) #end (d) h1 -
20.✍️ Which property is set to bold in this rule?
h2 {
font-size: 20px;
text-align: center;
font-weight: bold;
} (a) font-weight (b) width (c) border (d) bold - 21.✍️ In color: blue; which part is the value? (a) ; (b) color (c) blue (d) :
-
22.🖌️ Where does the text sit on its line?
li {
text-align: left;
background-color: orange;
color: red;
font-size: 20px;
} (a) in the middle (b) on the left (c) on the right -
23.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 80px;
padding: 10px;
border: 3px solid black;
margin: 10px;
} - 24.💪 Which flexbox property sets space between boxes? (a) align-items (b) flex-direction (c) display: flex (d) gap
-
25.🖌️ How big is the text, in px?
li {
text-align: left;
color: yellow;
font-size: 16px;
background-color: black;
} -
26.✍️ Which property is set to yellow in this rule?
#top {
font-style: italic;
background-color: yellow;
color: red;
font-size: 20px;
} (a) margin (b) background-color (c) padding (d) yellow -
27.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 2 boxes, each 80px wide (no margins). - 28.🔍 Which is the odd one out? (a) gives the page structure (b) puts a picture on a page (c) makes a link (d) adds space around boxes
- 29.True or false: #top is an id selector. (a) False (b) True
- 30.💪 Which justify-content value equal gaps, none at ends? (a) flex-end (b) center (c) flex-start (d) space-between
- 31.🎨 Which tag holds CSS inside the head? (a) <css> (b) <script> (c) <style> (d) <body>
-
32.⚖️ What colour is the text of this element?
<h2 class="red" id="hero">Hi</h2>
CSS:
h2 { color: green; }
h2 { color: white; } (a) green (b) yellow (c) blue (d) white -
33.✍️ Which property is set to red in this rule?
.note {
background-color: yellow;
font-weight: bold;
color: red;
} (a) color (b) red (c) text-align (d) font-size -
34.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 360px;
justify-content: flex-end;
}
Inside are 3 boxes, each 100px wide (no margins). -
35.⚖️ What colour is the text of this element?
<h1 class="note" id="intro">Hi</h1>
CSS:
.note { color: blue; }
.note { color: purple; } (a) purple (b) black (c) red (d) blue - 36.True or false: padding is a solid or dotted edge. (a) True (b) False
-
37.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
padding: 8px;
width: 300px;
} - 38.True or false: #hero is an element selector. (a) False (b) True
- 39.🖌️ Which CSS property colours behind the text? (a) background-color (b) text-align (c) font-weight (d) font-family
- 40.🌈 Which colour of light is strongest in rgb(211, 31, 109)? (a) green (b) blue (c) red
Answer key
- a class selector
- 268
- <h2 class="menu">
- { }
- red
- blue
- align-items
- False
- :
- blue
- sets colours and fonts
- 20
- makes headings and lists
- bright green
- blue
- an id selector
- span
- makes a form box
- #end
- font-weight
- blue
- on the left
- 126
- gap
- 16
- background-color
- 50
- adds space around boxes
- True
- space-between
- <style>
- white
- color
- 60
- purple
- False
- 2
- False
- background-color
- red
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids