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 colour is the text of this element?
<h2 class="note" id="hero">Hi</h2>
CSS:
#hero { color: purple; }
#hero { color: red; } (a) yellow (b) red (c) purple (d) green - 2.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
- 3.🎯 What kind of selector is #main? (a) an id selector (b) a class selector (c) an element selector
- 4.✍️ CSS declarations go inside which brackets? (a) [ ] (b) { } (c) < > (d) ( )
- 5.🌈 Hex digits go 0 to 9, then A to which letter? (a) F (b) G (c) Z (d) J
- 6.📦 In the box model, which part is a solid or dotted edge? (a) border (b) margin (c) padding (d) content
- 7.True or false: CSS sets colours and fonts. (a) True (b) False
-
8.🖌️ What colour are the letters?
h1 {
background-color: blue;
text-align: center;
color: purple;
font-size: 32px;
} (a) purple (b) blue (c) yellow -
9.🖌️ Where does the text sit on its line?
h2 {
color: red;
font-size: 40px;
background-color: blue;
text-align: left;
} (a) in the middle (b) on the left (c) on the right -
10.✍️ Which property is set to 20px in this rule?
.note {
font-size: 20px;
border: 2px solid;
} (a) text-align (b) font-size (c) 20px (d) background-color - 11.What does background-color do? (a) picks the font style (b) sets the letter colour (c) makes the text bold (d) colours behind the text
-
12.🖌️ What colour is behind the letters?
li {
background-color: green;
font-size: 32px;
text-align: center;
color: orange;
} (a) orange (b) white (c) green -
13.🎯 Which CSS selector matches this element?
<div class="red" id="intro">Hello</div> (a) .red (b) #red (c) span (d) #main - 14.🎯 Which element does the selector h2 style? (a) <h2 class="menu"> (b) <li> (c) <div class="menu"> (d) <span id="end">
-
15.⚖️ What colour is the text of this element?
<h2 class="box" id="hero">Hi</h2>
CSS:
#hero { color: orange; }
#hero { color: purple; } (a) orange (b) green (c) purple (d) white -
16.🖌️ What colour is behind the letters?
h2 {
font-size: 36px;
background-color: red;
text-align: right;
color: white;
} (a) white (b) green (c) red -
17.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 160px;
padding: 20px;
border: 3px solid black;
margin: 15px;
} -
18.🖌️ What colour is behind the letters?
li {
font-size: 40px;
color: red;
text-align: center;
background-color: white;
} (a) red (b) blue (c) white - 19.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 6 (b) 2 (c) 3 (d) 4
-
20.✍️ What value is given to font-size in this rule?
h1 {
font-size: 20px;
padding: 8px;
text-align: center;
} (a) font-size (b) center (c) yellow (d) 20px -
21.✍️ What is the selector in this CSS rule?
.box {
border: 2px solid;
font-weight: bold;
} (a) .box (b) bold (c) border (d) h2 - 22.What does font-size do? (a) picks the font style (b) makes letters bigger (c) sets the letter colour (d) centres a heading
- 23.🌈 In #rrggbb, which colour do the last two digits give? (a) white (b) blue (c) red (d) green
- 24.✍️ Which sign ends each CSS declaration? (a) . (b) ; (c) : (d) ,
- 25.🎯 Can many elements share the same class? (a) Yes (b) No
-
26.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 14px;
}
} (a) No (b) Yes -
27.⚖️ What colour is the text of this element?
<h1 class="big" id="main">Hi</h1>
CSS:
.big { color: purple; }
.big { color: blue; } (a) purple (b) blue (c) yellow (d) orange - 28.True or false: HTML adds space around boxes. (a) False (b) True
-
29.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 390px;
justify-content: flex-start;
}
Inside are 4 boxes, each 80px wide (no margins). -
30.🎯 Which CSS selector matches this element?
<span class="box" id="top">Hello</span> (a) .top (b) #box (c) #top (d) p -
31.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 180px;
padding: 15px;
border: 2px solid black;
margin: 20px;
} -
32.✍️ What is the selector in this CSS rule?
body {
padding: 8px;
font-size: 20px;
} (a) padding (b) 20px (c) .box (d) body -
33.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 26px;
}
} - 34.🎯 What kind of selector is #top? (a) an element selector (b) a class selector (c) an id selector
-
35.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 30px;
}
} - 36.💪 Which justify-content value equal gaps, none at ends? (a) center (b) flex-end (c) flex-start (d) space-between
- 37.🖌️ Which CSS property picks the font style? (a) background-color (b) color (c) font-family (d) font-size
- 38.🌈 In #rrggbb, which colour do the first two digits give? (a) blue (b) green (c) red (d) black
- 39.🌈 Which colour is rgb(255, 0, 255)? (a) yellow (b) bright green (c) magenta (d) red
-
40.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 200px;
padding: 5px;
border: 1px solid black;
margin: 15px;
}
Answer key
- red
- an id selector
- an id selector
- { }
- F
- border
- True
- purple
- on the left
- font-size
- colours behind the text
- green
- .red
- <h2 class="menu">
- purple
- red
- 236
- white
- 3
- 20px
- .box
- makes letters bigger
- blue
- ;
- Yes
- No
- blue
- False
- 70
- #top
- 254
- body
- 26
- an id selector
- 24
- space-between
- font-family
- red
- magenta
- 242
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids