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 colour is the text of this element?
<h2 class="big" id="logo">Hi</h2>
CSS:
.big { color: purple; }
.big { color: black; } (a) purple (b) red (c) yellow (d) black -
2.✍️ What is the selector in this CSS rule?
.note {
font-weight: bold;
padding: 8px;
background-color: yellow;
color: red;
} (a) font-weight (b) 8px (c) .note (d) #top - 3.✍️ CSS declarations go inside which brackets? (a) < > (b) [ ] (c) ( ) (d) { }
-
4.🖌️ Where does the text sit on its line?
p {
background-color: purple;
text-align: right;
font-size: 12px;
color: black;
} (a) in the middle (b) on the right (c) on the left - 5.True or false: margin is space inside the border. (a) True (b) False
- 6.🎯 Can many elements share the same class? (a) No (b) Yes
- 7.📱 Responsive design means a page ___. (a) is only for laptops (b) fits every screen (c) never changes (d) has no pictures
- 8.🌈 Which colour is #ff00ff? (a) blue (b) black (c) white (d) magenta
- 9.🌈 Which colour is rgb(0, 0, 255)? (a) cyan (b) white (c) blue (d) red
- 10.🌈 Which colour is #00ffff? (a) black (b) red (c) blue (d) cyan
- 11.🎯 What kind of selector is .card? (a) an element selector (b) an id selector (c) a class selector
-
12.⚖️ What colour is the text of this element?
<h1 class="big" id="top">Hi</h1>
CSS:
h1 { color: black; }
h1 { color: red; } (a) red (b) black (c) green (d) purple - 13.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) 800px or wider (c) exactly 100px (d) 800px or narrower
-
14.🎯 Which CSS selector matches this element?
<div class="star" id="intro">Hello</div> (a) div (b) span (c) .intro (d) #star - 15.True or false: the content is space inside the border. (a) True (b) False
-
16.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 300px;
padding: 5px;
border: 5px solid black;
margin: 10px;
} - 17.🌈 Which colour is #0000ff? (a) bright green (b) blue (c) magenta (d) red
- 18.🎯 Which element does the selector .red style? (a) <h1 class="box"> (b) <h1 id="red"> (c) <h2 class="star"> (d) <h1 class="red">
- 19.📦 In the box model, which part is the line round the box? (a) content (b) border (c) padding (d) margin
-
20.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 90px;
justify-content: flex-end;
}
Inside are 2 boxes, each 40px wide (no margins). -
21.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 6px;
}
} -
22.🖌️ What colour is behind the letters?
p {
background-color: orange;
color: black;
text-align: left;
font-size: 12px;
} (a) orange (b) black (c) red - 23.🔍 Which is the odd one out? (a) lays out the page (b) sets colours and fonts (c) adds space around boxes (d) puts a picture on a page
- 24.🧩 Which language makes a link? (a) CSS (b) HTML (c) JavaScript
-
25.🖌️ How big is the text, in px?
p {
font-size: 24px;
background-color: purple;
color: orange;
text-align: left;
} -
26.✍️ Which property is set to 300px in this rule?
.box {
font-size: 20px;
font-weight: bold;
background-color: yellow;
width: 300px;
} (a) color (b) font-style (c) width (d) 300px -
27.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 180px;
justify-content: center;
}
Inside are 4 boxes, each 40px wide (no margins). - 28.📦 In the box model, which part is a solid or dotted edge? (a) border (b) margin (c) content (d) padding
- 29.🎨 A CSS file usually ends with which extension? (a) .png (b) .css (c) .html (d) .js
- 30.True or false: CSS rounds box corners. (a) True (b) False
-
31.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 110px;
padding: 20px;
border: 3px solid black;
margin: 20px;
} - 32.🌈 In #rrggbb, which colour do the last two digits give? (a) white (b) red (c) blue (d) green
- 33.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
- 34.True or false: #main is an id selector. (a) True (b) False
-
35.🖌️ What colour is behind the letters?
h1 {
font-size: 16px;
color: red;
text-align: right;
background-color: black;
} (a) black (b) green (c) red -
36.✍️ What is the selector in this CSS rule?
h1 {
text-align: center;
color: red;
} (a) red (b) text-align (c) p (d) h1 - 37.🌈 In #690000 the red part is the hex number 69. What is it as a normal number?
- 38.Which of these is the content? (a) space inside the border (b) the line round the box (c) the text or picture (d) the gap to other boxes
- 39.🧩 Which language changes the text size? (a) JavaScript (b) HTML (c) CSS
- 40.💪 Which flexbox property turns on flexbox? (a) align-items (b) gap (c) justify-content (d) display: flex
Answer key
- black
- .note
- { }
- on the right
- False
- Yes
- fits every screen
- magenta
- blue
- cyan
- a class selector
- red
- 800px or wider
- div
- False
- 340
- blue
- <h1 class="red">
- border
- 10
- 6
- orange
- puts a picture on a page
- HTML
- 24
- width
- 10
- border
- .css
- True
- 196
- blue
- an element selector
- True
- black
- h1
- 105
- the text or picture
- CSS
- display: flex
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids