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.🧩 Which language makes a form box? (a) JavaScript (b) CSS (c) HTML
- 2.🔍 Which is the odd one out? (a) adds space around boxes (b) rounds box corners (c) changes the text size (d) changes the page live
- 3.🧩 Which language gives the page structure? (a) HTML (b) CSS (c) JavaScript
-
4.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 200px;
padding: 20px;
border: 1px solid black;
margin: 10px;
} -
5.✍️ How many declarations (property: value pairs) are in this rule?
li {
font-weight: bold;
text-align: center;
} -
6.⚖️ What colour is the text of this element?
<h2 class="menu" id="end">Hi</h2>
CSS:
h2 { color: red; }
.menu { color: green; } (a) orange (b) blue (c) red (d) green - 7.🎯 What kind of selector is li? (a) an id selector (b) a class selector (c) an element selector
-
8.🖌️ Where does the text sit on its line?
h1 {
color: orange;
text-align: center;
background-color: yellow;
font-size: 12px;
} (a) on the left (b) on the right (c) in the middle - 9.✍️ Which sign goes between a property and its value? (a) ; (b) - (c) : (d) =
-
10.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-size: 20px;
} - 11.✍️ In color: blue; which part is the value? (a) color (b) blue (c) : (d) ;
-
12.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 1024px) {
p {
font-size: 18px;
}
} - 13.True or false: .star is a class selector. (a) True (b) False
-
14.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 200px;
padding: 30px;
border: 4px solid black;
margin: 0px;
} - 15.📱 min-width: 800px applies when the screen is ___. (a) 800px or wider (b) exactly 100px (c) turned off (d) 800px or narrower
- 16.What does background-color do? (a) sets the letter colour (b) centres a heading (c) colours behind the text (d) makes the text bold
- 17.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 2 (b) 4 (c) 3 (d) 6
-
18.⚖️ What colour is the text of this element?
<h1 class="red" id="top">Hi</h1>
CSS:
#top { color: yellow; }
h1 { color: green; } (a) green (b) yellow (c) orange (d) red - 19.🌈 In #00009d the blue part is the hex number 9d. What is it as a normal number?
-
20.🖌️ How big is the text, in px?
h2 {
text-align: center;
font-size: 32px;
background-color: yellow;
color: green;
} - 21.True or false: JavaScript makes headings and lists. (a) True (b) False
- 22.🌈 Which hex code is blue? (a) #ffff00 (b) #ff0000 (c) #000000 (d) #0000ff
-
23.🎯 Which CSS selector matches this element?
<span class="big" id="top">Hello</span> (a) .top (b) span (c) #intro (d) .red -
24.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 16px;
}
} - 25.What does color do? (a) colours behind the text (b) makes letters bigger (c) centres a heading (d) sets the letter colour
- 26.📦 In the box model, which part is the text or picture? (a) padding (b) border (c) content (d) margin
- 27.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or narrower (c) turned off (d) 600px or wider
-
28.🖌️ Where does the text sit on its line?
h2 {
background-color: red;
text-align: center;
color: orange;
font-size: 40px;
} (a) in the middle (b) on the left (c) on the right -
29.🖌️ Where does the text sit on its line?
h2 {
color: red;
text-align: right;
font-size: 32px;
background-color: green;
} (a) on the left (b) on the right (c) in the middle - 30.What does justify-content: center 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
-
31.🖌️ What colour are the letters?
h2 {
text-align: center;
font-size: 36px;
color: red;
background-color: orange;
} (a) red (b) blue (c) orange - 32.🎯 Which element does the selector .note style? (a) <h1 class="note"> (b) <h1 id="note"> (c) <h2 class="red"> (d) <h1 class="big">
- 33.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
-
34.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 20px;
}
} - 35.Which of these does HTML do? (a) counts down a timer (b) sets colours and fonts (c) shows a pop-up message (d) makes headings and lists
- 36.📱 Which tag helps phones show a page at the right size? (a) the viewport meta tag (b) the hr tag (c) the title tag (d) the br tag
-
37.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 280px;
justify-content: flex-end;
}
Inside are 2 boxes, each 100px wide (no margins). - 38.🎯 Can many elements share the same class? (a) Yes (b) No
- 39.🎨 One CSS file can style how many pages? (a) only one word (b) many pages (c) no pages (d) only one image
-
40.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 240px;
justify-content: flex-start;
}
Inside are 4 boxes, each 50px wide (no margins).
Answer key
- HTML
- changes the page live
- HTML
- 262
- 2
- green
- an element selector
- in the middle
- :
- 1
- blue
- 18
- True
- 268
- 800px or wider
- colours behind the text
- 3
- yellow
- 157
- 32
- False
- #0000ff
- span
- 16
- sets the letter colour
- content
- 600px or narrower
- in the middle
- on the right
- puts boxes in the middle
- red
- <h1 class="note">
- an id selector
- 24
- makes headings and lists
- the viewport meta tag
- 80
- Yes
- many pages
- 40
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids