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.True or false: body is an id selector. (a) True (b) False
-
2.⚖️ What colour is the text of this element?
<h1 class="note" id="hero">Hi</h1>
CSS:
#hero { color: green; }
h1 { color: yellow; }
.note { color: white; } (a) yellow (b) white (c) green (d) red - 3.💪 Which justify-content value equal gaps, none at ends? (a) center (b) flex-end (c) flex-start (d) space-between
- 4.🌈 Which colour is rgb(255, 0, 0)? (a) blue (b) white (c) red (d) cyan
-
5.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 18px;
}
} - 6.🔍 Which is the odd one out? (a) checks a quiz answer (b) reacts to a button click (c) puts a picture on a page (d) shows a pop-up message
- 7.🧩 Which language puts a picture on a page? (a) CSS (b) JavaScript (c) HTML
- 8.🌈 Which colour is #ffff00? (a) bright green (b) yellow (c) black (d) blue
- 9.🌈 Which colour is #0000ff? (a) red (b) yellow (c) white (d) blue
- 10.True or false: HTML puts a picture on a page. (a) True (b) False
-
11.⚖️ What colour is the text of this element?
<p class="red" id="top">Hi</p>
CSS:
.red { color: orange; }
.red { color: white; } (a) purple (b) orange (c) white (d) green -
12.✍️ Which property is set to center in this rule?
h1 {
text-align: center;
font-style: italic;
} (a) center (b) margin (c) text-align (d) background-color -
13.🖌️ What colour are the letters?
h1 {
text-align: right;
background-color: yellow;
font-size: 12px;
color: white;
} (a) white (b) yellow (c) green - 14.🌈 Which hex code is magenta? (a) #00ffff (b) #00ff00 (c) #ffff00 (d) #ff00ff
- 15.🖌️ Which CSS property colours behind the text? (a) font-weight (b) background-color (c) font-size (d) text-align
-
16.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 20px;
}
} - 17.🎯 What kind of selector is h1? (a) an element selector (b) an id selector (c) a class selector
-
18.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 280px;
padding: 5px;
border: 3px solid black;
margin: 5px;
} - 19.📦 In the box model, which part is space inside the border? (a) margin (b) padding (c) border (d) content
- 20.🎨 A CSS file usually ends with which extension? (a) .html (b) .css (c) .js (d) .png
- 21.🌈 In #0000c2 the blue part is the hex number c2. What is it as a normal number?
- 22.True or false: img is an id selector. (a) False (b) True
- 23.🌈 In #00006f the blue part is the hex number 6f. What is it as a normal number?
- 24.🖌️ Which CSS property makes the text bold? (a) font-size (b) text-align (c) color (d) font-weight
- 25.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the hr tag (c) the viewport meta tag (d) the br tag
-
26.🖌️ What colour is behind the letters?
li {
color: red;
background-color: black;
font-size: 20px;
text-align: center;
} (a) red (b) black (c) green - 27.💪 Which flexbox property picks row or column? (a) align-items (b) flex-direction (c) display: flex (d) gap
- 28.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 2 (b) 3 (c) 6 (d) 4
-
29.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 80px;
padding: 5px;
border: 1px solid black;
margin: 10px;
} -
30.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 130px;
justify-content: flex-start;
}
Inside are 2 boxes, each 50px wide (no margins). - 31.✍️ Which sign goes between a property and its value? (a) - (b) = (c) : (d) ;
-
32.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 16px;
}
} (a) Yes (b) No - 33.What does font-size do? (a) makes the text bold (b) centres a heading (c) sets the letter colour (d) makes letters bigger
- 34.🌈 Which colour of light is strongest in rgb(236, 66, 7)? (a) red (b) green (c) blue
- 35.✍️ Which sign ends each CSS declaration? (a) . (b) : (c) , (d) ;
- 36.🌈 Which colour is rgb(255, 255, 0)? (a) yellow (b) magenta (c) blue (d) white
-
37.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 22px;
}
} (a) Yes (b) No -
38.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 300px;
justify-content: center;
}
Inside are 3 boxes, each 60px wide (no margins). - 39.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) black (c) blue (d) red
- 40.🖌️ Which CSS property centres a heading? (a) font-family (b) text-align (c) background-color (d) color
Answer key
- False
- green
- space-between
- red
- 12
- puts a picture on a page
- HTML
- yellow
- blue
- True
- white
- text-align
- white
- #ff00ff
- background-color
- 16
- an element selector
- 306
- padding
- .css
- 194
- False
- 111
- font-weight
- the viewport meta tag
- black
- flex-direction
- 3
- 112
- 30
- :
- Yes
- makes letters bigger
- red
- ;
- yellow
- Yes
- 60
- red
- text-align
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids