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) an id selector (b) a class selector (c) an element selector
- 2.📦 In the box model, which part is the line round the box? (a) margin (b) padding (c) content (d) border
- 3.🎯 What kind of selector is .card? (a) an element selector (b) an id selector (c) a class selector
-
4.✍️ How many declarations (property: value pairs) are in this rule?
body {
padding: 8px;
} -
5.⚖️ What colour is the text of this element?
<h2 class="star" id="top">Hi</h2>
CSS:
.star { color: black; }
h2 { color: red; }
#top { color: orange; } (a) red (b) orange (c) black (d) purple -
6.✍️ What value is given to margin in this rule?
h2 {
margin: 10px;
padding: 8px;
border: 2px solid;
color: red;
} (a) 10px (b) 8px (c) margin (d) bold - 7.📱 What does a media query check? (a) the page title (b) the time of day (c) the screen width (d) the battery level
- 8.True or false: HTML changes the text size. (a) False (b) True
-
9.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-style: italic;
border: 2px solid;
background-color: yellow;
} -
10.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 70px;
padding: 15px;
border: 5px solid black;
margin: 5px;
} - 11.🧩 Which language gives the page structure? (a) JavaScript (b) HTML (c) CSS
- 12.🌈 Which hex code is yellow? (a) #ff00ff (b) #ff0000 (c) #0000ff (d) #ffff00
-
13.🖌️ Where does the text sit on its line?
h1 {
font-size: 20px;
text-align: center;
background-color: black;
color: red;
} (a) on the left (b) in the middle (c) on the right -
14.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 270px;
padding: 30px;
border: 2px solid black;
margin: 5px;
} - 15.True or false: JavaScript shows a pop-up message. (a) False (b) True
- 16.🌈 Which colour is #ff0000? (a) blue (b) white (c) bright green (d) red
-
17.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 1024px) {
p {
font-size: 20px;
}
} (a) No (b) Yes -
18.✍️ What is the selector in this CSS rule?
h1 {
font-size: 20px;
background-color: yellow;
} (a) p (b) font-size (c) yellow (d) h1 - 19.🎯 Which sign starts a class selector? (a) . (b) & (c) @ (d) #
-
20.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
margin: 10px;
font-weight: bold;
color: red;
padding: 8px;
} -
21.⚖️ What colour is the text of this element?
<h2 class="menu" id="logo">Hi</h2>
CSS:
#logo { color: purple; }
#logo { color: white; } (a) orange (b) purple (c) black (d) white - 22.🖌️ Which CSS property makes letters bigger? (a) color (b) background-color (c) font-size (d) text-align
-
23.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 400px;
justify-content: space-between;
}
Inside are 3 boxes, each 100px wide (no margins). -
24.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 18px;
}
} -
25.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} -
26.⚖️ What colour is the text of this element?
<h2 class="note" id="hero">Hi</h2>
CSS:
h2 { color: orange; }
#hero { color: purple; }
.note { color: green; } (a) blue (b) purple (c) green (d) orange - 27.🎯 How many elements on a page should have the same id? (a) 2 (b) 1 (c) any number (d) 5
- 28.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
- 29.🌈 In #2a0000 the red part is the hex number 2a. What is it as a normal number?
-
30.✍️ Which property is set to 20px in this rule?
.box {
font-style: italic;
font-size: 20px;
} (a) text-align (b) background-color (c) font-size (d) 20px - 31.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) white (c) red (d) green
- 32.🔍 Which is the odd one out? (a) changes the text size (b) sets colours and fonts (c) counts down a timer (d) lays out the page
-
33.✍️ What is the selector in this CSS rule?
.note {
font-weight: bold;
padding: 8px;
background-color: yellow;
} (a) font-weight (b) 8px (c) .note (d) #top -
34.🖌️ What colour are the letters?
p {
color: white;
font-size: 12px;
text-align: right;
background-color: purple;
} (a) orange (b) purple (c) white - 35.💪 Which flexbox property picks row or column? (a) gap (b) display: flex (c) justify-content (d) flex-direction
-
36.⚖️ What colour is the text of this element?
<h2 class="big" id="logo">Hi</h2>
CSS:
h2 { color: red; }
h2 { color: orange; } (a) red (b) white (c) green (d) orange -
37.⚖️ What colour is the text of this element?
<h2 class="red" id="main">Hi</h2>
CSS:
.red { color: white; }
.red { color: black; } (a) yellow (b) purple (c) white (d) black - 38.📦 In the box model, which part is a solid or dotted edge? (a) border (b) padding (c) margin (d) content
- 39.🌈 Which colour of light is strongest in rgb(158, 58, 35)? (a) blue (b) red (c) green
-
40.✍️ Which property is set to bold in this rule?
p {
font-weight: bold;
font-size: 20px;
} (a) bold (b) width (c) font-weight (d) border
Answer key
- a class selector
- border
- a class selector
- 1
- orange
- 10px
- the screen width
- False
- 3
- 110
- HTML
- #ffff00
- in the middle
- 334
- True
- red
- No
- h1
- .
- 4
- white
- font-size
- 50
- 16
- 10
- purple
- 1
- an element selector
- 42
- font-size
- blue
- counts down a timer
- .note
- white
- flex-direction
- orange
- black
- border
- red
- font-weight
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids