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 are the letters?
h2 {
background-color: yellow;
font-size: 28px;
color: black;
text-align: center;
} (a) yellow (b) orange (c) black -
2.🎯 Which CSS selector matches this element?
<h2 class="big" id="top">Hello</h2> (a) .red (b) h2 (c) #intro (d) #big -
3.🖌️ What colour is behind the letters?
li {
background-color: black;
text-align: center;
color: green;
font-size: 20px;
} (a) green (b) black (c) purple -
4.⚖️ What colour is the text of this element?
<h1 class="menu" id="main">Hi</h1>
CSS:
.menu { color: green; }
#main { color: white; }
h1 { color: orange; } (a) black (b) green (c) white (d) orange -
5.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 230px;
justify-content: flex-start;
}
Inside are 2 boxes, each 100px wide (no margins). -
6.🎯 Which CSS selector matches this element?
<h2 class="box" id="top">Hello</h2> (a) #intro (b) li (c) h2 (d) .star -
7.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 22px;
}
} (a) No (b) Yes -
8.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 20px;
}
} (a) Yes (b) No - 9.🎨 Which attribute adds CSS inside one tag? (a) href (b) alt (c) style (d) src
-
10.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 60px;
padding: 15px;
border: 2px solid black;
margin: 20px;
} -
11.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 1024px) {
p {
font-size: 24px;
}
} - 12.Which of these is the content? (a) space inside the border (b) the gap to other boxes (c) the gap round content (d) the text or picture
- 13.🔍 Which is the odd one out? (a) rounds box corners (b) sets colours and fonts (c) adds space around boxes (d) changes the page live
-
14.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 290px;
padding: 15px;
border: 1px solid black;
margin: 20px;
} - 15.🧩 Which language lays out the page? (a) HTML (b) CSS (c) JavaScript
- 16.✍️ How does a CSS comment start? (a) # (b) // (c) <!-- (d) /*
-
17.🖌️ What colour are the letters?
h1 {
font-size: 20px;
background-color: black;
text-align: center;
color: blue;
} (a) black (b) orange (c) blue - 18.🧩 Which language puts a picture on a page? (a) JavaScript (b) CSS (c) HTML
- 19.🎨 A CSS file usually ends with which extension? (a) .js (b) .css (c) .html (d) .png
- 20.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 3 (b) 4 (c) 2 (d) 6
-
21.🖌️ Where does the text sit on its line?
h1 {
background-color: blue;
font-size: 32px;
color: red;
text-align: right;
} (a) on the right (b) on the left (c) in the middle -
22.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 240px;
padding: 5px;
border: 4px solid black;
margin: 10px;
} - 23.🎯 Which sign starts an id selector? (a) @ (b) & (c) # (d) .
- 24.True or false: the border is space inside the border. (a) False (b) True
-
25.🎯 Which CSS selector matches this element?
<h2 class="red" id="hero">Hello</h2> (a) .box (b) #top (c) #hero (d) #red - 26.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
-
27.🖌️ What colour are the letters?
h1 {
background-color: white;
color: green;
font-size: 20px;
text-align: center;
} (a) green (b) white (c) black -
28.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 280px;
justify-content: flex-start;
}
Inside are 4 boxes, each 50px wide (no margins). - 29.📦 In the box model, which part is the text or picture? (a) margin (b) padding (c) border (d) content
-
30.✍️ What is the selector in this CSS rule?
h2 {
text-align: center;
background-color: yellow;
margin: 10px;
} (a) h2 (b) h1 (c) text-align (d) yellow -
31.🎯 Which CSS selector matches this element?
<div class="box" id="end">Hello</div> (a) .end (b) .star (c) span (d) div - 32.💪 Which justify-content value puts boxes in the middle? (a) flex-start (b) space-between (c) center (d) flex-end
- 33.🌈 In #rrggbb, which colour do the last two digits give? (a) white (b) red (c) green (d) blue
-
34.⚖️ What colour is the text of this element?
<h2 class="menu" id="hero">Hi</h2>
CSS:
#hero { color: orange; }
#hero { color: red; } (a) red (b) yellow (c) black (d) orange -
35.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 1024px) {
p {
font-size: 18px;
}
} -
36.🖌️ What colour are the letters?
h1 {
color: purple;
font-size: 36px;
background-color: white;
text-align: center;
} (a) white (b) black (c) purple - 37.🌈 Which hex code is blue? (a) #0000ff (b) #000000 (c) #ff0000 (d) #ffff00
- 38.What does background-color do? (a) centres a heading (b) colours behind the text (c) makes the text bold (d) sets the letter colour
- 39.True or false: CSS makes headings and lists. (a) True (b) False
-
40.🖌️ What colour is behind the letters?
li {
text-align: center;
color: red;
font-size: 36px;
background-color: green;
} (a) green (b) purple (c) red
Answer key
- black
- h2
- black
- white
- 30
- h2
- Yes
- Yes
- style
- 134
- 20
- the text or picture
- changes the page live
- 322
- CSS
- /*
- blue
- HTML
- .css
- 3
- on the right
- 258
- #
- False
- #hero
- an id selector
- green
- 80
- content
- h2
- div
- center
- blue
- red
- 18
- purple
- #0000ff
- colours behind the text
- False
- green
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids