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 many pairs of hex digits are in a colour like #ff8800? (a) 2 (b) 4 (c) 6 (d) 3
- 2.Which of these does JavaScript do? (a) makes a form box (b) adds space around boxes (c) checks a quiz answer (d) changes the text size
-
3.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} (a) No (b) Yes - 4.🎨 Which tag connects an outside CSS file? (a) <css> (b) <img> (c) <link> (d) <a>
-
5.🖌️ Where does the text sit on its line?
h2 {
background-color: black;
text-align: right;
font-size: 20px;
color: orange;
} (a) in the middle (b) on the right (c) on the left -
6.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 90px;
justify-content: space-between;
}
Inside are 2 boxes, each 40px wide (no margins). -
7.✍️ How many declarations (property: value pairs) are in this rule?
body {
font-weight: bold;
width: 300px;
padding: 8px;
} - 8.🎯 Which element does the selector #intro style? (a) <div class="intro"> (b) <div id="main"> (c) <span class="big"> (d) <div id="intro">
- 9.True or false: JavaScript rounds box corners. (a) True (b) False
-
10.🖌️ Where does the text sit on its line?
p {
background-color: yellow;
text-align: center;
font-size: 24px;
color: green;
} (a) on the left (b) on the right (c) in the middle -
11.⚖️ What colour is the text of this element?
<p class="big" id="main">Hi</p>
CSS:
#main { color: orange; }
#main { color: blue; } (a) green (b) red (c) blue (d) orange -
12.✍️ What value is given to text-align in this rule?
h2 {
background-color: yellow;
color: red;
text-align: center;
padding: 8px;
} (a) yellow (b) 10px (c) text-align (d) center -
13.🖌️ Where does the text sit on its line?
h1 {
background-color: orange;
font-size: 32px;
color: yellow;
text-align: right;
} (a) on the left (b) on the right (c) in the middle - 14.💪 Which flexbox property sets space between boxes? (a) gap (b) align-items (c) display: flex (d) justify-content
- 15.What does font-weight do? (a) centres a heading (b) sets the letter colour (c) makes letters bigger (d) makes the text bold
- 16.🌈 In #000091 the blue part is the hex number 91. What is it as a normal number?
-
17.✍️ What value is given to background-color in this rule?
body {
padding: 8px;
text-align: center;
border: 2px solid;
background-color: yellow;
} (a) 8px (b) background-color (c) 10px (d) yellow -
18.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 170px;
justify-content: flex-end;
}
Inside are 2 boxes, each 60px wide (no margins). - 19.🌈 Which colour of light is strongest in rgb(108, 156, 137)? (a) green (b) red (c) blue
-
20.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 50px;
padding: 10px;
border: 4px solid black;
margin: 15px;
} -
21.✍️ What is the selector in this CSS rule?
h2 {
color: red;
text-align: center;
margin: 10px;
} (a) h2 (b) center (c) color (d) h1 - 22.🧩 Which language adds space around boxes? (a) HTML (b) JavaScript (c) CSS
-
23.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 600px) {
p {
font-size: 18px;
}
} (a) No (b) Yes -
24.✍️ What is the selector in this CSS rule?
p {
background-color: yellow;
font-weight: bold;
} (a) p (b) bold (c) .note (d) background-color -
25.✍️ Which property is set to 8px in this rule?
h2 {
margin: 10px;
background-color: yellow;
padding: 8px;
} (a) padding (b) 8px (c) border (d) font-weight -
26.⚖️ What colour is the text of this element?
<h1 class="star" id="main">Hi</h1>
CSS:
h1 { color: white; }
#main { color: yellow; }
.star { color: green; } (a) yellow (b) white (c) blue (d) green -
27.✍️ Which property is set to 300px in this rule?
p {
color: red;
font-size: 20px;
width: 300px;
} (a) 300px (b) font-style (c) width (d) color - 28.What does justify-content: flex-start do? (a) packs boxes at the start (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the end
-
29.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 16px;
}
} - 30.🌈 Which colour is rgb(0, 255, 0)? (a) red (b) cyan (c) bright green (d) yellow
-
31.⚖️ What colour is the text of this element?
<p class="note" id="main">Hi</p>
CSS:
.note { color: black; }
#main { color: yellow; } (a) red (b) yellow (c) orange (d) black - 32.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the shorter one (c) the first one (d) neither
-
33.🎯 Which CSS selector matches this element?
<h2 class="big" id="top">Hello</h2> (a) li (b) #big (c) .big (d) #intro -
34.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 14px;
}
} - 35.✍️ CSS declarations go inside which brackets? (a) < > (b) ( ) (c) [ ] (d) { }
-
36.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 22px;
}
} - 37.🎯 Which element does the selector h1 style? (a) <li class="menu"> (b) <h1 class="menu"> (c) <div id="end"> (d) <h2>
- 38.✍️ Which sign goes between a property and its value? (a) - (b) ; (c) = (d) :
-
39.⚖️ What colour is the text of this element?
<h1 class="note" id="top">Hi</h1>
CSS:
#top { color: purple; }
#top { color: black; } (a) red (b) blue (c) purple (d) black - 40.💪 Which flexbox property turns on flexbox? (a) display: flex (b) align-items (c) gap (d) justify-content
Answer key
- 3
- checks a quiz answer
- Yes
- <link>
- on the right
- 10
- 3
- <div id="intro">
- False
- in the middle
- blue
- center
- on the right
- gap
- makes the text bold
- 145
- yellow
- 50
- green
- 108
- h2
- CSS
- Yes
- p
- padding
- yellow
- width
- packs boxes at the start
- 16
- bright green
- yellow
- the later one
- .big
- 20
- { }
- 24
- <h1 class="menu">
- :
- black
- display: flex
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids