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 is the odd one out? (a) shows a pop-up message (b) changes the page live (c) counts down a timer (d) puts a picture on a page
- 2.🌈 Which colour is #000000? (a) yellow (b) black (c) blue (d) red
-
3.✍️ What value is given to padding in this rule?
.note {
padding: 8px;
background-color: yellow;
} (a) bold (b) 2px solid (c) padding (d) 8px -
4.🖌️ Where does the text sit on its line?
li {
text-align: right;
background-color: yellow;
font-size: 12px;
color: white;
} (a) on the left (b) in the middle (c) on the right - 5.🎯 Which element does the selector h2 style? (a) <h2 class="big"> (b) <li> (c) <div class="big"> (d) <span id="main">
-
6.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 180px;
justify-content: flex-start;
}
Inside are 2 boxes, each 60px wide (no margins). -
7.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 16px;
}
} (a) No (b) Yes - 8.🎯 Which element does the selector .star style? (a) <h2 class="note"> (b) <h1 class="star"> (c) <h1 id="star"> (d) <h1 class="menu">
- 9.Which of these is the content? (a) space inside the border (b) the text or picture (c) the gap to other boxes (d) the line round the box
- 10.🔍 Which is the odd one out? (a) rounds box corners (b) shows a pop-up message (c) lays out the page (d) sets colours and fonts
- 11.💪 Which flexbox property lines boxes up across? (a) display: flex (b) justify-content (c) align-items (d) gap
- 12.Which of these does JavaScript do? (a) makes headings and lists (b) puts a picture on a page (c) makes a form box (d) shows a pop-up message
- 13.📦 In the box model, which part is a solid or dotted edge? (a) border (b) content (c) margin (d) padding
- 14.🎯 Which element does the selector span style? (a) <p> (b) <h2 id="intro"> (c) <span class="red"> (d) <h1 class="red">
- 15.🔍 Which is the odd one out? (a) adds space around boxes (b) checks a quiz answer (c) changes the text size (d) rounds box corners
-
16.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 16px;
}
} - 17.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) 600px or narrower (c) turned off (d) exactly 1000px
- 18.🎨 Which attribute adds CSS inside one tag? (a) alt (b) src (c) style (d) href
-
19.✍️ Which property is set to yellow in this rule?
h2 {
background-color: yellow;
margin: 10px;
color: red;
} (a) yellow (b) background-color (c) padding (d) margin -
20.⚖️ What colour is the text of this element?
<h2 class="star" id="logo">Hi</h2>
CSS:
#logo { color: purple; }
h2 { color: white; }
.star { color: blue; } (a) white (b) purple (c) orange (d) blue - 21.🎯 Which sign starts an id selector? (a) & (b) # (c) @ (d) .
- 22.🧩 Which language sets colours and fonts? (a) HTML (b) CSS (c) JavaScript
-
23.🖌️ What colour are the letters?
p {
text-align: left;
background-color: orange;
color: white;
font-size: 28px;
} (a) orange (b) red (c) white -
24.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 1024px) {
p {
font-size: 28px;
}
} - 25.True or false: CSS shows a pop-up message. (a) False (b) True
- 26.🌈 Which colour is #00ff00? (a) blue (b) black (c) bright green (d) magenta
- 27.🎨 A CSS file usually ends with which extension? (a) .js (b) .png (c) .css (d) .html
- 28.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
-
29.⚖️ What colour is the text of this element?
<p class="note" id="intro">Hi</p>
CSS:
#intro { color: black; }
#intro { color: yellow; } (a) purple (b) black (c) blue (d) yellow - 30.🎯 How many elements on a page should have the same id? (a) 5 (b) 1 (c) any number (d) 2
-
31.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 110px;
padding: 10px;
border: 2px solid black;
margin: 10px;
} -
32.✍️ What value is given to font-size in this rule?
h1 {
margin: 10px;
text-align: center;
font-size: 20px;
} (a) 20px (b) center (c) font-size (d) yellow - 33.🎯 Which element does the selector .red style? (a) <h2 id="red"> (b) <li class="star"> (c) <h2 class="box"> (d) <h2 class="red">
-
34.⚖️ What colour is the text of this element?
<p class="red" id="main">Hi</p>
CSS:
#main { color: red; }
#main { color: yellow; } (a) red (b) white (c) green (d) yellow - 35.🌈 Hex digits go 0 to 9, then A to which letter? (a) G (b) Z (c) J (d) F
- 36.What does font-family do? (a) makes letters bigger (b) sets the letter colour (c) makes the text bold (d) picks the font style
- 37.Which of these is margin? (a) a solid or dotted edge (b) the text or picture (c) space outside the border (d) the line round the box
- 38.🎯 What kind of selector is p? (a) an id selector (b) an element selector (c) a class selector
- 39.🧩 Which language counts down a timer? (a) CSS (b) JavaScript (c) HTML
-
40.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 16px;
}
}
Answer key
- puts a picture on a page
- black
- 8px
- on the right
- <h2 class="big">
- 60
- No
- <h1 class="star">
- the text or picture
- shows a pop-up message
- align-items
- shows a pop-up message
- border
- <span class="red">
- checks a quiz answer
- 20
- 600px or narrower
- style
- background-color
- purple
- #
- CSS
- white
- 24
- False
- bright green
- .css
- an element selector
- yellow
- 1
- 154
- 20px
- <h2 class="red">
- yellow
- F
- picks the font style
- space outside the border
- an element selector
- JavaScript
- 16
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids