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 selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
- 2.True or false: #top is an element selector. (a) False (b) True
-
3.⚖️ What colour is the text of this element?
<p class="menu" id="top">Hi</p>
CSS:
p { color: blue; }
#top { color: black; }
.menu { color: purple; } (a) blue (b) black (c) white (d) purple -
4.✍️ What value is given to border in this rule?
.note {
font-style: italic;
margin: 10px;
border: 2px solid;
} (a) 2px solid (b) border (c) italic (d) 300px - 5.📦 In the box model, which part is the gap round content? (a) border (b) margin (c) padding (d) content
-
6.⚖️ What colour is the text of this element?
<h2 class="note" id="intro">Hi</h2>
CSS:
h2 { color: orange; }
h2 { color: red; } (a) orange (b) blue (c) red (d) black - 7.🌈 Which hex code is red? (a) #ff00ff (b) #0000ff (c) #ffff00 (d) #ff0000
-
8.🎯 Which CSS selector matches this element?
<span class="note" id="end">Hello</span> (a) #note (b) span (c) .big (d) .end - 9.💪 Which flexbox property spaces boxes along a row? (a) gap (b) align-items (c) justify-content (d) flex-direction
-
10.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 310px;
justify-content: space-between;
}
Inside are 3 boxes, each 50px wide (no margins). - 11.🌈 In #0b0000 the red part is the hex number 0b. What is it as a normal number?
- 12.💪 Which justify-content value equal gaps, none at ends? (a) space-between (b) flex-end (c) center (d) flex-start
- 13.🎯 What kind of selector is #end? (a) an id selector (b) a class selector (c) an element selector
-
14.⚖️ What colour is the text of this element?
<h2 class="big" id="logo">Hi</h2>
CSS:
.big { color: orange; }
.big { color: white; } (a) orange (b) white (c) red (d) blue - 15.🎯 How many elements on a page should have the same id? (a) 2 (b) 5 (c) 1 (d) any number
- 16.🎯 What kind of selector is li? (a) a class selector (b) an element selector (c) an id selector
-
17.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 28px;
}
} (a) Yes (b) No - 18.🔍 Which is the odd one out? (a) makes a link (b) puts a picture on a page (c) lays out the page (d) makes headings and lists
- 19.🧩 Which language shows a pop-up message? (a) HTML (b) CSS (c) JavaScript
- 20.📦 In the box model, which part is space inside the border? (a) content (b) border (c) margin (d) padding
-
21.🖌️ Where does the text sit on its line?
h1 {
font-size: 32px;
color: white;
text-align: right;
background-color: black;
} (a) on the right (b) on the left (c) in the middle - 22.True or false: margin is space outside the border. (a) False (b) True
-
23.🖌️ What colour is behind the letters?
li {
color: green;
background-color: purple;
text-align: right;
font-size: 24px;
} (a) blue (b) green (c) purple -
24.✍️ What is the selector in this CSS rule?
p {
font-weight: bold;
border: 2px solid;
background-color: yellow;
} (a) .note (b) p (c) font-weight (d) 2px solid - 25.True or false: margin is the gap round content. (a) True (b) False
- 26.🌈 Which colour of light is strongest in rgb(31, 173, 24)? (a) blue (b) green (c) red
- 27.🔍 Which is the odd one out? (a) checks a quiz answer (b) counts down a timer (c) shows a pop-up message (d) adds space around boxes
- 28.What does font-size do? (a) picks the font style (b) colours behind the text (c) makes the text bold (d) makes letters bigger
- 29.✍️ CSS declarations go inside which brackets? (a) { } (b) [ ] (c) ( ) (d) < >
-
30.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 240px;
justify-content: center;
}
Inside are 2 boxes, each 60px wide (no margins). -
31.✍️ What value is given to color in this rule?
#top {
text-align: center;
font-style: italic;
color: red;
width: 300px;
} (a) 20px (b) color (c) center (d) red - 32.💪 Which flexbox property picks row or column? (a) display: flex (b) gap (c) flex-direction (d) align-items
-
33.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 270px;
padding: 10px;
border: 4px solid black;
margin: 20px;
} - 34.What does text-align do? (a) makes letters bigger (b) sets the letter colour (c) picks the font style (d) centres a heading
-
35.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 380px;
justify-content: center;
}
Inside are 3 boxes, each 80px wide (no margins). -
36.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 2 boxes, each 100px wide (no margins). - 37.True or false: JavaScript puts a picture on a page. (a) True (b) False
-
38.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 50px;
padding: 20px;
border: 4px solid black;
margin: 15px;
} - 39.What does background-color do? (a) picks the font style (b) makes letters bigger (c) colours behind the text (d) sets the letter colour
- 40.🌈 Which hex code is bright green? (a) #0000ff (b) #00ffff (c) #ffffff (d) #00ff00
Answer key
- an element selector
- False
- black
- 2px solid
- padding
- red
- #ff0000
- span
- justify-content
- 80
- 11
- space-between
- an id selector
- white
- 1
- an element selector
- No
- lays out the page
- JavaScript
- padding
- on the right
- True
- purple
- p
- False
- green
- adds space around boxes
- makes letters bigger
- { }
- 60
- red
- flex-direction
- 338
- centres a heading
- 70
- 30
- False
- 128
- colours behind the text
- #00ff00
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids