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 is the selector in this CSS rule?
body {
padding: 8px;
margin: 10px;
background-color: yellow;
font-size: 20px;
} (a) padding (b) .box (c) body (d) 10px -
2.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 320px;
justify-content: flex-start;
}
Inside are 3 boxes, each 100px wide (no margins). - 3.🌈 Hex digits go 0 to 9, then A to which letter? (a) J (b) Z (c) G (d) F
-
4.🎯 Which CSS selector matches this element?
<div class="menu" id="hero">Hello</div> (a) .note (b) div (c) #top (d) .hero - 5.💪 Which flexbox property spaces boxes along a row? (a) align-items (b) display: flex (c) justify-content (d) gap
- 6.True or false: padding is the line round the box. (a) True (b) False
- 7.🖌️ Which CSS property colours behind the text? (a) font-family (b) font-size (c) color (d) background-color
-
8.✍️ What is the selector in this CSS rule?
p {
text-align: center;
font-weight: bold;
} (a) p (b) .note (c) bold (d) text-align - 9.✍️ Which sign goes between a property and its value? (a) : (b) - (c) ; (d) =
- 10.🌈 Which colour of light is strongest in rgb(226, 19, 117)? (a) red (b) green (c) blue
-
11.🖌️ How big is the text, in px?
li {
text-align: left;
font-size: 20px;
background-color: orange;
color: red;
} - 12.True or false: CSS makes headings and lists. (a) False (b) True
- 13.🎨 Which tag connects an outside CSS file? (a) <a> (b) <link> (c) <css> (d) <img>
- 14.💪 Which justify-content value equal gaps, none at ends? (a) center (b) flex-start (c) flex-end (d) space-between
-
15.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 80px;
padding: 5px;
border: 3px solid black;
margin: 5px;
} -
16.🖌️ What colour is behind the letters?
h1 {
text-align: right;
font-size: 12px;
background-color: green;
color: white;
} (a) green (b) white (c) black - 17.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 4 (b) 3 (c) 6 (d) 2
- 18.🎯 How many elements on a page should have the same id? (a) 5 (b) 2 (c) 1 (d) any number
-
19.✍️ How many declarations (property: value pairs) are in this rule?
.note {
border: 2px solid;
text-align: center;
width: 300px;
} -
20.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 30px;
}
} -
21.✍️ How many declarations (property: value pairs) are in this rule?
body {
margin: 10px;
font-weight: bold;
color: red;
text-align: center;
} -
22.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 12px;
}
} - 23.True or false: .note is an id selector. (a) False (b) True
-
24.🖌️ What colour are the letters?
p {
background-color: black;
color: yellow;
text-align: left;
font-size: 40px;
} (a) yellow (b) black (c) blue - 25.🌈 Which colour of light is strongest in rgb(78, 162, 110)? (a) blue (b) red (c) green
-
26.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} (a) No (b) Yes -
27.✍️ How many declarations (property: value pairs) are in this rule?
#top {
font-weight: bold;
width: 300px;
} - 28.🌈 Which colour is rgb(0, 255, 0)? (a) cyan (b) magenta (c) black (d) bright green
- 29.🧩 Which language rounds box corners? (a) HTML (b) CSS (c) JavaScript
- 30.🌈 Which colour is rgb(255, 0, 0)? (a) red (b) blue (c) magenta (d) yellow
- 31.🎯 Which element does the selector h2 style? (a) <li> (b) <h2 class="menu"> (c) <span id="end"> (d) <div class="menu">
-
32.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 20px;
}
} (a) No (b) Yes -
33.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 8px;
}
} -
34.⚖️ What colour is the text of this element?
<p class="menu" id="main">Hi</p>
CSS:
#main { color: red; }
p { color: white; } (a) blue (b) green (c) red (d) white - 35.🌈 In #rrggbb, which colour do the first two digits give? (a) blue (b) black (c) red (d) green
-
36.⚖️ What colour is the text of this element?
<h2 class="box" id="end">Hi</h2>
CSS:
.box { color: purple; }
.box { color: black; } (a) black (b) white (c) purple (d) yellow - 37.Which of these does HTML do? (a) checks a quiz answer (b) sets colours and fonts (c) makes a form box (d) adds space around boxes
- 38.True or false: #logo is an id selector. (a) True (b) False
- 39.True or false: the border is the text or picture. (a) True (b) False
- 40.🌈 Which colour is #ff0000? (a) cyan (b) bright green (c) blue (d) red
Answer key
- body
- 20
- F
- div
- justify-content
- False
- background-color
- p
- :
- red
- 20
- False
- <link>
- space-between
- 106
- green
- 3
- 1
- 3
- 30
- 4
- 16
- False
- yellow
- green
- Yes
- 2
- bright green
- CSS
- red
- <h2 class="menu">
- No
- 12
- red
- red
- black
- makes a form box
- True
- False
- red
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids