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 much space across (px) does this box take in all, margin included?
.box {
width: 100px;
padding: 30px;
border: 2px solid black;
margin: 5px;
} - 2.✍️ How does a CSS comment start? (a) // (b) /* (c) <!-- (d) #
- 3.🌈 In #920000 the red part is the hex number 92. What is it as a normal number?
- 4.🎯 Which element does the selector .menu style? (a) <h1 class="menu"> (b) <h1 class="note"> (c) <h2 class="big"> (d) <h1 id="menu">
-
5.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 90px;
padding: 10px;
border: 1px solid black;
margin: 15px;
} - 6.📱 What does a media query check? (a) the time of day (b) the page title (c) the battery level (d) the screen width
-
7.✍️ Which property is set to 2px solid in this rule?
p {
border: 2px solid;
font-weight: bold;
} (a) border (b) 2px solid (c) font-style (d) width -
8.🖌️ What colour are the letters?
li {
text-align: left;
font-size: 24px;
color: green;
background-color: red;
} (a) green (b) red (c) blue - 9.🔍 Which is the odd one out? (a) counts down a timer (b) makes a form box (c) shows a pop-up message (d) checks a quiz answer
- 10.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) neither (c) the shorter one (d) the later one
-
11.⚖️ What colour is the text of this element?
<p class="red" id="intro">Hi</p>
CSS:
p { color: red; }
p { color: black; } (a) black (b) blue (c) red (d) yellow - 12.🧩 Which language checks a quiz answer? (a) HTML (b) JavaScript (c) CSS
-
13.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 8px;
}
} - 14.📦 In the box model, which part is space outside the border? (a) margin (b) padding (c) content (d) border
-
15.🖌️ What colour is behind the letters?
h1 {
text-align: center;
color: white;
background-color: purple;
font-size: 32px;
} (a) black (b) purple (c) white -
16.🖌️ What colour is behind the letters?
li {
text-align: left;
font-size: 40px;
color: red;
background-color: white;
} (a) white (b) red (c) yellow - 17.🎯 Can many elements share the same class? (a) No (b) Yes
- 18.What does text-align do? (a) picks the font style (b) centres a heading (c) sets the letter colour (d) makes the text bold
-
19.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 60px;
padding: 10px;
border: 4px solid black;
margin: 5px;
} - 20.⚖️ Which selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
- 21.🌈 Which colour is rgb(0, 0, 255)? (a) blue (b) magenta (c) red (d) black
- 22.🌈 In #rrggbb, which colour do the first two digits give? (a) blue (b) black (c) green (d) red
-
23.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 22px;
}
} - 24.🧩 Which language reacts to a button click? (a) HTML (b) JavaScript (c) CSS
- 25.📦 In the box model, which part is the line round the box? (a) content (b) padding (c) border (d) margin
-
26.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 120px;
justify-content: flex-end;
}
Inside are 2 boxes, each 40px wide (no margins). - 27.🧩 Which language shows a pop-up message? (a) JavaScript (b) HTML (c) CSS
-
28.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 480px;
justify-content: flex-end;
}
Inside are 4 boxes, each 100px wide (no margins). -
29.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
font-size: 20px;
} - 30.🌈 In #004000 the green part is the hex number 40. What is it as a normal number?
- 31.What does color do? (a) makes the text bold (b) makes letters bigger (c) picks the font style (d) sets the letter colour
-
32.⚖️ What colour is the text of this element?
<h1 class="menu" id="intro">Hi</h1>
CSS:
h1 { color: white; }
h1 { color: orange; } (a) red (b) white (c) blue (d) orange - 33.Which of these does JavaScript do? (a) lays out the page (b) makes headings and lists (c) reacts to a button click (d) adds space around boxes
- 34.Which of these does HTML do? (a) makes a link (b) lays out the page (c) checks a quiz answer (d) reacts to a button click
- 35.🌈 In #c30000 the red part is the hex number c3. What is it as a normal number?
-
36.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 20px;
}
} - 37.🎯 What kind of selector is p? (a) an element selector (b) an id selector (c) a class selector
- 38.🌈 Which colour is #00ff00? (a) red (b) magenta (c) blue (d) bright green
- 39.💪 Which flexbox property turns on flexbox? (a) align-items (b) justify-content (c) gap (d) display: flex
-
40.⚖️ What colour is the text of this element?
<h2 class="note" id="main">Hi</h2>
CSS:
#main { color: blue; }
#main { color: green; } (a) white (b) green (c) yellow (d) blue
Answer key
- 174
- /*
- 146
- <h1 class="menu">
- 142
- the screen width
- border
- green
- makes a form box
- the later one
- black
- JavaScript
- 12
- margin
- purple
- white
- Yes
- centres a heading
- 98
- an id selector
- blue
- red
- 16
- JavaScript
- border
- 40
- JavaScript
- 80
- 1
- 64
- sets the letter colour
- orange
- reacts to a button click
- makes a link
- 195
- 20
- an element selector
- bright green
- display: flex
- green
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids