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 wide (px) is each gap between two boxes?
.row {
display: flex;
width: 230px;
justify-content: space-between;
}
Inside are 2 boxes, each 100px wide (no margins). -
2.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 320px;
justify-content: flex-start;
}
Inside are 3 boxes, each 80px wide (no margins). -
3.🖌️ Where does the text sit on its line?
h1 {
font-size: 20px;
text-align: center;
background-color: purple;
color: orange;
} (a) in the middle (b) on the left (c) on the right - 4.🎯 How many elements on a page should have the same id? (a) 1 (b) any number (c) 2 (d) 5
- 5.🎯 Which sign starts a class selector? (a) @ (b) # (c) . (d) &
- 6.True or false: img is an element selector. (a) True (b) False
- 7.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
-
8.🖌️ What colour are the letters?
h2 {
background-color: blue;
text-align: right;
color: red;
font-size: 36px;
} (a) blue (b) black (c) red -
9.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 220px;
padding: 15px;
border: 4px solid black;
margin: 5px;
} - 10.✍️ CSS declarations go inside which brackets? (a) ( ) (b) < > (c) { } (d) [ ]
- 11.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) red (c) black (d) blue
- 12.📱 Responsive design means a page ___. (a) has no pictures (b) never changes (c) is only for laptops (d) fits every screen
-
13.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 460px;
justify-content: flex-end;
}
Inside are 4 boxes, each 100px wide (no margins). -
14.✍️ Which property is set to 8px in this rule?
p {
padding: 8px;
border: 2px solid;
font-size: 20px;
} (a) border (b) font-weight (c) 8px (d) padding -
15.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 6px;
}
} -
16.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 190px;
padding: 30px;
border: 2px solid black;
margin: 20px;
} - 17.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the viewport meta tag (c) the hr tag (d) the br tag
- 18.🔍 Which is the odd one out? (a) changes the text size (b) sets colours and fonts (c) adds space around boxes (d) puts a picture on a page
- 19.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the first one (c) the shorter one (d) the later one
- 20.📱 max-width: 600px applies when the screen is ___. (a) 600px or narrower (b) 600px or wider (c) exactly 1000px (d) turned off
-
21.✍️ What is the selector in this CSS rule?
body {
background-color: yellow;
margin: 10px;
padding: 8px;
border: 2px solid;
} (a) .box (b) 10px (c) background-color (d) body -
22.✍️ Which property is set to italic in this rule?
.note {
padding: 8px;
background-color: yellow;
font-size: 20px;
font-style: italic;
} (a) font-size (b) italic (c) font-style (d) color - 23.📦 In the box model, which part is the gap round content? (a) border (b) padding (c) margin (d) content
-
24.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 20px;
}
} - 25.True or false: the content is space inside the border. (a) False (b) True
- 26.🌈 Which hex code is white? (a) #00ff00 (b) #00ffff (c) #ff0000 (d) #ffffff
- 27.🎯 Which sign starts an id selector? (a) # (b) @ (c) & (d) .
-
28.🎯 Which CSS selector matches this element?
<span class="red" id="end">Hello</span> (a) #hero (b) .red (c) .box (d) #red - 29.🔍 Which is the odd one out? (a) counts down a timer (b) checks a quiz answer (c) shows a pop-up message (d) changes the text size
-
30.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 350px;
justify-content: flex-start;
}
Inside are 4 boxes, each 80px wide (no margins). - 31.🖌️ Which CSS property colours behind the text? (a) background-color (b) font-size (c) color (d) font-family
- 32.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
- 33.💪 Which flexbox property spaces boxes along a row? (a) display: flex (b) flex-direction (c) align-items (d) justify-content
- 34.True or false: JavaScript makes a link. (a) True (b) False
- 35.🔍 Which is the odd one out? (a) rounds box corners (b) checks a quiz answer (c) adds space around boxes (d) sets colours and fonts
-
36.⚖️ What colour is the text of this element?
<h2 class="note" id="top">Hi</h2>
CSS:
h2 { color: yellow; }
h2 { color: orange; } (a) yellow (b) orange (c) red (d) purple - 37.📦 In the box model, which part is a solid or dotted edge? (a) border (b) content (c) padding (d) margin
- 38.🎯 What kind of selector is body? (a) an element selector (b) a class selector (c) an id selector
-
39.⚖️ What colour is the text of this element?
<h2 class="red" id="end">Hi</h2>
CSS:
.red { color: orange; }
#end { color: blue; } (a) green (b) black (c) orange (d) blue -
40.🖌️ What colour are the letters?
li {
background-color: green;
font-size: 20px;
text-align: left;
color: white;
} (a) yellow (b) white (c) green
Answer key
- 30
- 80
- in the middle
- 1
- .
- True
- an element selector
- red
- 268
- { }
- red
- fits every screen
- 60
- padding
- 6
- 294
- the viewport meta tag
- puts a picture on a page
- the later one
- 600px or narrower
- body
- font-style
- padding
- 20
- False
- #ffffff
- #
- .red
- changes the text size
- 30
- background-color
- an id selector
- justify-content
- False
- checks a quiz answer
- orange
- border
- an element selector
- blue
- white
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids