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.🌈 In #ad0000 the red part is the hex number ad. What is it as a normal number?
-
2.🖌️ Where does the text sit on its line?
h2 {
font-size: 40px;
text-align: center;
color: blue;
background-color: red;
} (a) on the right (b) on the left (c) in the middle - 3.🎯 What kind of selector is #end? (a) a class selector (b) an id selector (c) an element selector
-
4.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 24px;
}
} - 5.🎯 Which element does the selector .big style? (a) <h2 class="red"> (b) <h2 class="big"> (c) <li class="box"> (d) <h2 id="big">
- 6.🎯 Can many elements share the same class? (a) No (b) Yes
-
7.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} -
8.✍️ What value is given to margin in this rule?
h1 {
font-weight: bold;
width: 300px;
font-style: italic;
margin: 10px;
} (a) 10px (b) margin (c) bold (d) 8px - 9.💪 Which justify-content value packs boxes at the end? (a) flex-start (b) flex-end (c) center (d) space-between
-
10.🎯 Which CSS selector matches this element?
<h1 class="note" id="hero">Hello</h1> (a) .hero (b) #top (c) h1 (d) #note -
11.✍️ What is the selector in this CSS rule?
h2 {
font-weight: bold;
font-size: 20px;
padding: 8px;
} (a) h2 (b) font-weight (c) h1 (d) 20px - 12.🌈 Which colour of light is strongest in rgb(88, 150, 83)? (a) blue (b) green (c) red
-
13.✍️ How many declarations (property: value pairs) are in this rule?
body {
margin: 10px;
} - 14.💪 Which justify-content value equal gaps, none at ends? (a) center (b) flex-start (c) flex-end (d) space-between
-
15.🖌️ Where does the text sit on its line?
h1 {
text-align: center;
font-size: 24px;
color: black;
background-color: yellow;
} (a) on the right (b) in the middle (c) on the left -
16.🖌️ What colour is behind the letters?
h1 {
font-size: 16px;
text-align: center;
background-color: green;
color: black;
} (a) black (b) purple (c) green -
17.⚖️ What colour is the text of this element?
<h1 class="big" id="end">Hi</h1>
CSS:
h1 { color: yellow; }
.big { color: blue; } (a) blue (b) yellow (c) white (d) green - 18.Which of these does HTML do? (a) reacts to a button click (b) changes the page live (c) makes headings and lists (d) adds space around boxes
-
19.⚖️ What colour is the text of this element?
<p class="big" id="main">Hi</p>
CSS:
.big { color: purple; }
.big { color: white; } (a) orange (b) purple (c) white (d) blue - 20.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the viewport meta tag (c) the br tag (d) the title tag
-
21.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 180px;
justify-content: flex-start;
}
Inside are 3 boxes, each 50px wide (no margins). -
22.✍️ What is the selector in this CSS rule?
h1 {
width: 300px;
color: red;
background-color: yellow;
} (a) width (b) red (c) p (d) h1 - 23.🌈 Which colour is #00ff00? (a) bright green (b) magenta (c) white (d) black
- 24.🔍 Which is the odd one out? (a) shows a pop-up message (b) gives the page structure (c) makes a form box (d) puts a picture on a page
- 25.💪 Which flexbox property picks row or column? (a) justify-content (b) flex-direction (c) align-items (d) gap
-
26.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 768px) {
p {
font-size: 12px;
}
} (a) No (b) Yes - 27.🎯 What kind of selector is #top? (a) an id selector (b) an element selector (c) a class selector
- 28.True or false: h1 is an id selector. (a) True (b) False
- 29.What does background-color do? (a) centres a heading (b) colours behind the text (c) makes letters bigger (d) sets the letter colour
-
30.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 140px;
padding: 10px;
border: 5px solid black;
margin: 0px;
} - 31.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
-
32.✍️ What value is given to background-color in this rule?
h1 {
background-color: yellow;
color: red;
} (a) background-color (b) 10px (c) yellow (d) 8px - 33.🌈 Hex digits go 0 to 9, then A to which letter? (a) F (b) Z (c) G (d) J
-
34.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 170px;
padding: 15px;
border: 5px solid black;
margin: 0px;
} - 35.True or false: img is a class selector. (a) True (b) False
-
36.⚖️ What colour is the text of this element?
<p class="menu" id="top">Hi</p>
CSS:
#top { color: black; }
#top { color: blue; } (a) blue (b) red (c) black (d) yellow - 37.🌈 Which colour of light is strongest in rgb(159, 16, 104)? (a) red (b) green (c) blue
-
38.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 20px;
}
} -
39.⚖️ What colour is the text of this element?
<h2 class="big" id="logo">Hi</h2>
CSS:
.big { color: blue; }
.big { color: green; } (a) white (b) green (c) blue (d) black - 40.🧩 Which language makes headings and lists? (a) JavaScript (b) CSS (c) HTML
Answer key
- 173
- in the middle
- an id selector
- 20
- <h2 class="big">
- Yes
- 18
- 10px
- flex-end
- h1
- h2
- green
- 1
- space-between
- in the middle
- green
- blue
- makes headings and lists
- white
- the viewport meta tag
- 30
- h1
- bright green
- shows a pop-up message
- flex-direction
- Yes
- an id selector
- False
- colours behind the text
- 170
- an id selector
- yellow
- F
- 210
- False
- blue
- red
- 16
- green
- HTML
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids