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 is the text of this element?
<h1 class="big" id="hero">Hi</h1>
CSS:
h1 { color: purple; }
#hero { color: white; } (a) purple (b) green (c) white (d) orange - 2.What does background-color do? (a) sets the letter colour (b) colours behind the text (c) makes letters bigger (d) picks the font style
-
3.✍️ What is the selector in this CSS rule?
.box {
background-color: yellow;
font-size: 20px;
} (a) 20px (b) h2 (c) .box (d) background-color - 4.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) turned off (c) 600px or narrower (d) 600px or wider
-
5.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} - 6.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the shorter one (c) the later one (d) the first one
- 7.🧩 Which language changes the text size? (a) HTML (b) CSS (c) JavaScript
- 8.🖌️ Which CSS property centres a heading? (a) font-size (b) font-weight (c) text-align (d) background-color
-
9.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 32px;
}
} -
10.🖌️ What colour is behind the letters?
h1 {
font-size: 24px;
background-color: blue;
text-align: center;
color: purple;
} (a) blue (b) purple (c) green -
11.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 210px;
padding: 30px;
border: 5px solid black;
margin: 5px;
} -
12.⚖️ What colour is the text of this element?
<h1 class="red" id="logo">Hi</h1>
CSS:
.red { color: red; }
.red { color: green; } (a) white (b) blue (c) green (d) red - 13.True or false: #logo is an id selector. (a) True (b) False
- 14.🖌️ Which CSS property colours behind the text? (a) font-family (b) text-align (c) background-color (d) font-weight
-
15.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 120px;
justify-content: flex-start;
}
Inside are 2 boxes, each 50px wide (no margins). - 16.True or false: the content is the line round the box. (a) True (b) False
- 17.🌈 Which colour is #ff0000? (a) magenta (b) red (c) black (d) cyan
- 18.🌈 In #0000f4 the blue part is the hex number f4. What is it as a normal number?
- 19.🔍 Which is the odd one out? (a) shows a pop-up message (b) changes the page live (c) reacts to a button click (d) gives the page structure
- 20.💪 Which flexbox property turns on flexbox? (a) justify-content (b) flex-direction (c) gap (d) display: flex
- 21.🌈 Which hex code is bright green? (a) #ff0000 (b) #00ff00 (c) #ff00ff (d) #0000ff
-
22.🎯 Which CSS selector matches this element?
<span class="note" id="main">Hello</span> (a) #main (b) #note (c) p (d) .big -
23.⚖️ What colour is the text of this element?
<h2 class="red" id="end">Hi</h2>
CSS:
.red { color: orange; }
h2 { color: red; } (a) green (b) orange (c) red (d) blue - 24.✍️ How does a CSS comment start? (a) <!-- (b) // (c) # (d) /*
-
25.✍️ How many declarations (property: value pairs) are in this rule?
body {
margin: 10px;
padding: 8px;
width: 300px;
border: 2px solid;
} -
26.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 26px;
}
} (a) No (b) Yes -
27.✍️ Which property is set to 20px in this rule?
.box {
font-weight: bold;
background-color: yellow;
text-align: center;
font-size: 20px;
} (a) background-color (b) 20px (c) text-align (d) font-size - 28.🎯 Which element does the selector .menu style? (a) <span class="note"> (b) <span class="menu"> (c) <p class="big"> (d) <span id="menu">
-
29.✍️ What is the selector in this CSS rule?
li {
font-weight: bold;
font-size: 20px;
text-align: center;
} (a) body (b) font-weight (c) 20px (d) li - 30.🎯 Which element does the selector #intro style? (a) <li class="red"> (b) <h2 id="main"> (c) <h2 id="intro"> (d) <h2 class="intro">
- 31.True or false: padding is the gap round content. (a) True (b) False
-
32.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 210px;
padding: 30px;
border: 2px solid black;
margin: 5px;
} - 33.Which of these is padding? (a) the gap to other boxes (b) the gap round content (c) the line round the box (d) the text or picture
- 34.🔍 Which is the odd one out? (a) makes a form box (b) makes a link (c) gives the page structure (d) changes the text size
-
35.🎯 Which CSS selector matches this element?
<li class="box" id="main">Hello</li> (a) #box (b) div (c) .main (d) .box - 36.🔍 Which is the odd one out? (a) shows a pop-up message (b) changes the page live (c) adds space around boxes (d) checks a quiz answer
-
37.⚖️ What colour is the text of this element?
<h2 class="note" id="top">Hi</h2>
CSS:
#top { color: black; }
#top { color: orange; } (a) black (b) blue (c) green (d) orange - 38.Which of these does JavaScript do? (a) puts a picture on a page (b) makes a link (c) reacts to a button click (d) adds space around boxes
- 39.True or false: the border is the line round the box. (a) False (b) True
- 40.True or false: #logo is a class selector. (a) False (b) True
Answer key
- white
- colours behind the text
- .box
- 600px or narrower
- 10
- the later one
- CSS
- text-align
- 32
- blue
- 290
- green
- True
- background-color
- 20
- False
- red
- 244
- gives the page structure
- display: flex
- #00ff00
- #main
- orange
- /*
- 4
- No
- font-size
- <span class="menu">
- li
- <h2 id="intro">
- True
- 284
- the gap round content
- changes the text size
- .box
- adds space around boxes
- orange
- reacts to a button click
- True
- False
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids