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 #rrggbb, which colour do the last two digits give? (a) blue (b) white (c) green (d) red
-
2.✍️ How many declarations (property: value pairs) are in this rule?
p {
background-color: yellow;
color: red;
text-align: center;
} - 3.What does font-size do? (a) centres a heading (b) sets the letter colour (c) picks the font style (d) makes letters bigger
-
4.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 32px;
}
} -
5.✍️ Which property is set to 8px in this rule?
li {
text-align: center;
padding: 8px;
background-color: yellow;
} (a) 8px (b) border (c) font-weight (d) padding - 6.What does font-weight do? (a) centres a heading (b) makes the text bold (c) picks the font style (d) makes letters bigger
-
7.✍️ What is the selector in this CSS rule?
#top {
background-color: yellow;
color: red;
text-align: center;
} (a) red (b) li (c) background-color (d) #top - 8.📱 Responsive design means a page ___. (a) fits every screen (b) has no pictures (c) is only for laptops (d) never changes
- 9.True or false: #main is an id selector. (a) False (b) True
- 10.Which of these does JavaScript do? (a) rounds box corners (b) checks a quiz answer (c) makes headings and lists (d) sets colours and fonts
- 11.🎯 What kind of selector is img? (a) an element selector (b) a class selector (c) an id selector
- 12.🔍 Which is the odd one out? (a) adds space around boxes (b) lays out the page (c) changes the text size (d) makes headings and lists
- 13.🌈 Which colour is #ff00ff? (a) white (b) yellow (c) red (d) magenta
-
14.🖌️ What colour is behind the letters?
p {
text-align: left;
background-color: black;
font-size: 32px;
color: blue;
} (a) blue (b) green (c) black - 15.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
- 16.What does justify-content: flex-start do? (a) packs boxes at the end (b) puts boxes in the middle (c) packs boxes at the start (d) equal gaps, none at ends
- 17.🌈 Which colour is #ff0000? (a) yellow (b) red (c) cyan (d) blue
-
18.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 290px;
padding: 30px;
border: 1px solid black;
margin: 10px;
} -
19.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 360px;
justify-content: center;
}
Inside are 4 boxes, each 50px wide (no margins). -
20.⚖️ What colour is the text of this element?
<h2 class="box" id="intro">Hi</h2>
CSS:
.box { color: blue; }
#intro { color: black; } (a) black (b) red (c) blue (d) orange -
21.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 768px) {
p {
font-size: 32px;
}
} - 22.🧩 Which language shows a pop-up message? (a) JavaScript (b) CSS (c) HTML
-
23.🎯 Which CSS selector matches this element?
<p class="box" id="intro">Hello</p> (a) h1 (b) .intro (c) #main (d) .box - 24.💪 Which flexbox property picks row or column? (a) flex-direction (b) align-items (c) justify-content (d) gap
-
25.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 90px;
justify-content: flex-start;
}
Inside are 2 boxes, each 40px wide (no margins). - 26.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) 800px or wider (c) 800px or narrower (d) exactly 100px
- 27.🌈 Which colour of light is strongest in rgb(174, 97, 75)? (a) red (b) green (c) blue
- 28.True or false: JavaScript checks a quiz answer. (a) True (b) False
-
29.⚖️ What colour is the text of this element?
<p class="big" id="end">Hi</p>
CSS:
p { color: orange; }
p { color: red; } (a) orange (b) blue (c) white (d) red -
30.🖌️ How big is the text, in px?
h1 {
font-size: 40px;
text-align: left;
color: red;
background-color: white;
} -
31.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 150px;
justify-content: flex-end;
}
Inside are 2 boxes, each 40px wide (no margins). -
32.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 18px;
}
} (a) Yes (b) No - 33.True or false: CSS checks a quiz answer. (a) False (b) True
-
34.⚖️ What colour is the text of this element?
<h2 class="note" id="logo">Hi</h2>
CSS:
#logo { color: purple; }
#logo { color: white; } (a) green (b) purple (c) white (d) red - 35.✍️ How does a CSS comment start? (a) <!-- (b) // (c) # (d) /*
- 36.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the br tag (c) the title tag (d) the viewport meta tag
- 37.🌈 Which hex code is yellow? (a) #ffff00 (b) #ff00ff (c) #000000 (d) #0000ff
-
38.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 1024px) {
p {
font-size: 14px;
}
} -
39.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 20px;
}
} (a) Yes (b) No - 40.🎯 Which element does the selector .star style? (a) <span id="star"> (b) <span class="menu"> (c) <span class="star"> (d) <p class="note">
Answer key
- blue
- 3
- makes letters bigger
- 24
- padding
- makes the text bold
- #top
- fits every screen
- True
- checks a quiz answer
- an element selector
- makes headings and lists
- magenta
- black
- an element selector
- packs boxes at the start
- red
- 372
- 80
- black
- 32
- JavaScript
- .box
- flex-direction
- 10
- 800px or wider
- red
- True
- red
- 40
- 70
- No
- False
- white
- /*
- the viewport meta tag
- #ffff00
- 20
- No
- <span class="star">
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids