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) a class selector (c) an element selector
-
2.🖌️ What colour is behind the letters?
h2 {
font-size: 36px;
background-color: purple;
color: yellow;
text-align: center;
} (a) yellow (b) green (c) purple -
3.🖌️ What colour is behind the letters?
p {
background-color: blue;
font-size: 28px;
text-align: left;
color: red;
} (a) red (b) green (c) blue -
4.✍️ How many declarations (property: value pairs) are in this rule?
.box {
border: 2px solid;
color: red;
text-align: center;
} -
5.⚖️ What colour is the text of this element?
<h1 class="big" id="top">Hi</h1>
CSS:
.big { color: white; }
.big { color: green; } (a) white (b) green (c) purple (d) yellow -
6.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 270px;
justify-content: flex-start;
}
Inside are 4 boxes, each 50px wide (no margins). -
7.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 270px;
padding: 10px;
border: 1px solid black;
margin: 10px;
} -
8.⚖️ What colour is the text of this element?
<p class="menu" id="top">Hi</p>
CSS:
#top { color: white; }
.menu { color: blue; } (a) yellow (b) black (c) white (d) blue - 9.🌈 Which colour is #ff0000? (a) magenta (b) black (c) red (d) white
-
10.⚖️ What colour is the text of this element?
<h2 class="star" id="intro">Hi</h2>
CSS:
.star { color: green; }
h2 { color: red; } (a) orange (b) yellow (c) red (d) green - 11.🌈 In #00000a the blue part is the hex number 0a. What is it as a normal number?
- 12.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 6 (b) 3 (c) 4 (d) 2
-
13.⚖️ What colour is the text of this element?
<p class="star" id="end">Hi</p>
CSS:
.star { color: orange; }
.star { color: yellow; } (a) green (b) black (c) orange (d) yellow - 14.🖌️ Which CSS property centres a heading? (a) text-align (b) color (c) font-size (d) font-family
- 15.💪 Which justify-content value packs boxes at the start? (a) flex-end (b) center (c) space-between (d) flex-start
-
16.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 26px;
}
} (a) Yes (b) No - 17.📱 Responsive design means a page ___. (a) has no pictures (b) fits every screen (c) is only for laptops (d) never changes
-
18.🖌️ What colour is behind the letters?
h2 {
text-align: left;
background-color: orange;
color: black;
font-size: 16px;
} (a) yellow (b) orange (c) black -
19.⚖️ What colour is the text of this element?
<p class="note" id="end">Hi</p>
CSS:
.note { color: blue; }
.note { color: white; } (a) blue (b) green (c) white (d) red -
20.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 150px;
justify-content: flex-start;
}
Inside are 2 boxes, each 60px wide (no margins). - 21.🧩 Which language changes the page live? (a) CSS (b) HTML (c) JavaScript
- 22.🌈 Which colour is #ff00ff? (a) yellow (b) white (c) red (d) magenta
- 23.✍️ How does a CSS comment start? (a) <!-- (b) /* (c) // (d) #
- 24.Which of these does JavaScript do? (a) gives the page structure (b) adds space around boxes (c) puts a picture on a page (d) changes the page live
-
25.⚖️ What colour is the text of this element?
<p class="big" id="end">Hi</p>
CSS:
p { color: orange; }
.big { color: green; } (a) orange (b) black (c) green (d) blue - 26.🌈 Which colour is #0000ff? (a) red (b) blue (c) yellow (d) black
-
27.⚖️ What colour is the text of this element?
<h2 class="menu" id="end">Hi</h2>
CSS:
#end { color: red; }
#end { color: blue; } (a) blue (b) purple (c) green (d) red -
28.⚖️ What colour is the text of this element?
<p class="red" id="end">Hi</p>
CSS:
#end { color: orange; }
.red { color: purple; } (a) blue (b) orange (c) purple (d) yellow - 29.💪 Which flexbox property picks row or column? (a) align-items (b) display: flex (c) flex-direction (d) justify-content
- 30.🌈 Which colour is #00ffff? (a) magenta (b) cyan (c) bright green (d) red
-
31.✍️ How many declarations (property: value pairs) are in this rule?
body {
font-style: italic;
} - 32.Which of these is margin? (a) space inside the border (b) space outside the border (c) the line round the box (d) the text or picture
-
33.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 110px;
padding: 10px;
border: 3px solid black;
margin: 10px;
} -
34.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 8px;
}
} (a) No (b) Yes - 35.What does background-color do? (a) colours behind the text (b) sets the letter colour (c) centres a heading (d) picks the font style
- 36.🔍 Which is the odd one out? (a) changes the text size (b) lays out the page (c) sets colours and fonts (d) makes a form box
-
37.⚖️ What colour is the text of this element?
<h2 class="star" id="hero">Hi</h2>
CSS:
#hero { color: blue; }
h2 { color: white; }
.star { color: yellow; } (a) green (b) blue (c) yellow (d) white - 38.🔍 Which is the odd one out? (a) rounds box corners (b) sets colours and fonts (c) changes the page live (d) lays out the page
-
39.✍️ What value is given to margin in this rule?
.note {
background-color: yellow;
margin: 10px;
} (a) margin (b) 8px (c) 10px (d) bold - 40.📦 In the box model, which part is the gap round content? (a) margin (b) border (c) content (d) padding
Answer key
- an element selector
- purple
- blue
- 3
- green
- 70
- 312
- white
- red
- green
- 10
- 3
- yellow
- text-align
- flex-start
- Yes
- fits every screen
- orange
- white
- 30
- JavaScript
- magenta
- /*
- changes the page live
- green
- blue
- blue
- orange
- flex-direction
- cyan
- 1
- space outside the border
- 156
- Yes
- colours behind the text
- makes a form box
- blue
- changes the page live
- 10px
- padding
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids