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 kind of selector is body? (a) an id selector (b) a class selector (c) an element selector
-
2.⚖️ What colour is the text of this element?
<p class="note" id="main">Hi</p>
CSS:
#main { color: green; }
#main { color: red; } (a) green (b) white (c) yellow (d) red -
3.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 12px;
}
} - 4.🔍 Which is the odd one out? (a) changes the page live (b) checks a quiz answer (c) changes the text size (d) reacts to a button click
- 5.🎯 Which element does the selector #hero style? (a) <h2 class="hero"> (b) <li class="box"> (c) <h2 id="top"> (d) <h2 id="hero">
-
6.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 210px;
justify-content: flex-start;
}
Inside are 2 boxes, each 100px wide (no margins). - 7.📦 In the box model, which part is the gap round content? (a) content (b) padding (c) border (d) margin
-
8.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 20px;
}
} -
9.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 60px;
padding: 25px;
border: 3px solid black;
margin: 5px;
} -
10.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 70px;
padding: 5px;
border: 5px solid black;
margin: 0px;
} - 11.✍️ In color: blue; which part is the value? (a) color (b) blue (c) ; (d) :
- 12.📦 In the box model, which part is the text or picture? (a) margin (b) content (c) border (d) padding
- 13.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
- 14.✍️ CSS declarations go inside which brackets? (a) { } (b) ( ) (c) [ ] (d) < >
- 15.What does justify-content: center do? (a) packs boxes at the start (b) puts boxes in the middle (c) packs boxes at the end (d) equal gaps, none at ends
- 16.💪 Which flexbox property lines boxes up across? (a) justify-content (b) align-items (c) display: flex (d) flex-direction
- 17.True or false: HTML puts a picture on a page. (a) True (b) False
- 18.True or false: .menu is an id selector. (a) False (b) True
-
19.🖌️ What colour is behind the letters?
p {
background-color: orange;
text-align: center;
font-size: 32px;
color: white;
} (a) yellow (b) white (c) orange - 20.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) exactly 100px (c) turned off (d) 800px or wider
- 21.✍️ How does a CSS comment start? (a) # (b) <!-- (c) // (d) /*
- 22.True or false: margin is the text or picture. (a) True (b) False
- 23.🎯 Which element does the selector h1 style? (a) <h2> (b) <div id="hero"> (c) <li class="red"> (d) <h1 class="red">
- 24.🌈 Which colour of light is strongest in rgb(33, 218, 105)? (a) blue (b) red (c) green
- 25.📱 What does a media query check? (a) the page title (b) the screen width (c) the time of day (d) the battery level
-
26.🎯 Which CSS selector matches this element?
<h1 class="note" id="intro">Hello</h1> (a) .big (b) h2 (c) #main (d) h1 - 27.Which of these is the border? (a) the gap round content (b) space inside the border (c) the line round the box (d) space outside the border
- 28.📦 In the box model, which part is a solid or dotted edge? (a) margin (b) padding (c) content (d) border
- 29.True or false: .note is an element selector. (a) False (b) True
-
30.✍️ Which property is set to 20px in this rule?
li {
width: 300px;
border: 2px solid;
font-size: 20px;
} (a) 20px (b) text-align (c) background-color (d) font-size - 31.🧩 Which language shows a pop-up message? (a) CSS (b) HTML (c) JavaScript
- 32.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or narrower (c) turned off (d) 600px or wider
- 33.🎯 What kind of selector is #top? (a) an element selector (b) a class selector (c) an id selector
- 34.🎯 Which element does the selector div style? (a) <span> (b) <p class="menu"> (c) <h1 id="intro"> (d) <div class="menu">
-
35.🎯 Which CSS selector matches this element?
<h1 class="big" id="logo">Hello</h1> (a) h1 (b) #end (c) #big (d) h2 -
36.🖌️ How big is the text, in px?
h1 {
background-color: white;
text-align: center;
font-size: 16px;
color: purple;
} - 37.Which of these is padding? (a) the text or picture (b) space outside the border (c) the line round the box (d) the gap round content
-
38.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 150px;
padding: 25px;
border: 3px solid black;
margin: 0px;
} - 39.What does justify-content: space-between do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the start (d) packs boxes at the end
- 40.🎨 A CSS file usually ends with which extension? (a) .js (b) .html (c) .png (d) .css
Answer key
- an element selector
- red
- 12
- changes the text size
- <h2 id="hero">
- 10
- padding
- 20
- 126
- 90
- blue
- content
- an id selector
- { }
- puts boxes in the middle
- align-items
- True
- False
- orange
- 800px or wider
- /*
- False
- <h1 class="red">
- green
- the screen width
- h1
- the line round the box
- border
- False
- font-size
- JavaScript
- 600px or narrower
- an id selector
- <div class="menu">
- h1
- 16
- the gap round content
- 206
- equal gaps, none at ends
- .css
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids