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.🖌️ Where does the text sit on its line?
h2 {
font-size: 20px;
text-align: right;
color: white;
background-color: orange;
} (a) on the left (b) on the right (c) in the middle - 2.📦 In the box model, which part is a solid or dotted edge? (a) content (b) border (c) padding (d) margin
-
3.⚖️ What colour is the text of this element?
<h2 class="big" id="top">Hi</h2>
CSS:
h2 { color: blue; }
h2 { color: black; } (a) red (b) blue (c) black (d) purple -
4.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 260px;
justify-content: flex-start;
}
Inside are 4 boxes, each 50px wide (no margins). - 5.🌈 Which colour of light is strongest in rgb(67, 49, 222)? (a) blue (b) green (c) red
-
6.🖌️ Where does the text sit on its line?
li {
background-color: white;
text-align: center;
font-size: 40px;
color: green;
} (a) on the left (b) in the middle (c) on the right - 7.🌈 Which colour is #000000? (a) yellow (b) blue (c) magenta (d) black
-
8.✍️ What is the selector in this CSS rule?
p {
width: 300px;
font-weight: bold;
text-align: center;
border: 2px solid;
} (a) .note (b) bold (c) p (d) width -
9.🎯 Which CSS selector matches this element?
<span class="star" id="main">Hello</span> (a) #logo (b) #main (c) #star (d) .menu -
10.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 320px;
justify-content: center;
}
Inside are 2 boxes, each 100px wide (no margins). - 11.True or false: .big is an element selector. (a) False (b) True
- 12.🌈 Which colour of light is strongest in rgb(75, 138, 218)? (a) red (b) blue (c) green
- 13.🔍 Which is the odd one out? (a) sets colours and fonts (b) shows a pop-up message (c) lays out the page (d) adds space around boxes
-
14.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 110px;
padding: 10px;
border: 3px solid black;
margin: 0px;
} - 15.🎯 Which element does the selector h2 style? (a) <li> (b) <span id="logo"> (c) <div class="menu"> (d) <h2 class="menu">
- 16.🎯 What kind of selector is body? (a) an id selector (b) an element selector (c) a class selector
- 17.True or false: padding is space outside the border. (a) True (b) False
-
18.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 22px;
}
} -
19.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 280px;
justify-content: center;
}
Inside are 2 boxes, each 100px wide (no margins). -
20.🖌️ What colour is behind the letters?
h2 {
font-size: 40px;
color: red;
text-align: right;
background-color: blue;
} (a) purple (b) red (c) blue - 21.What does justify-content: space-between do? (a) packs boxes at the start (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the end
- 22.🧩 Which language gives the page structure? (a) CSS (b) HTML (c) JavaScript
- 23.🎯 Which element does the selector p style? (a) <p class="menu"> (b) <h1> (c) <h2 class="menu"> (d) <li id="intro">
-
24.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 300px;
justify-content: space-between;
}
Inside are 4 boxes, each 60px wide (no margins). - 25.✍️ In color: blue; which part is the property? (a) ; (b) : (c) blue (d) color
-
26.⚖️ What colour is the text of this element?
<h1 class="note" id="intro">Hi</h1>
CSS:
#intro { color: yellow; }
#intro { color: purple; } (a) orange (b) purple (c) white (d) yellow - 27.🎯 What kind of selector is li? (a) an element selector (b) a class selector (c) an id selector
- 28.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
- 29.🎯 Which element does the selector p style? (a) <p class="red"> (b) <li id="end"> (c) <h1> (d) <h2 class="red">
-
30.📱 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;
}
} - 31.Which of these does CSS do? (a) gives the page structure (b) sets colours and fonts (c) makes headings and lists (d) makes a form box
- 32.🌈 Which hex code is bright green? (a) #00ffff (b) #ffff00 (c) #00ff00 (d) #000000
-
33.✍️ How many declarations (property: value pairs) are in this rule?
body {
font-weight: bold;
font-style: italic;
padding: 8px;
background-color: yellow;
} - 34.Which of these does HTML do? (a) changes the page live (b) gives the page structure (c) checks a quiz answer (d) lays out the page
- 35.🎨 What does CSS stand for? (a) Creative Sheet System (b) Colourful Site Styles (c) Cascading Style Sheets (d) Computer Style Sheets
-
36.⚖️ What colour is the text of this element?
<p class="big" id="intro">Hi</p>
CSS:
.big { color: green; }
#intro { color: black; }
p { color: orange; } (a) green (b) black (c) red (d) orange - 37.What does text-align do? (a) centres a heading (b) makes letters bigger (c) picks the font style (d) colours behind the text
- 38.What does font-size do? (a) makes letters bigger (b) colours behind the text (c) sets the letter colour (d) picks the font style
- 39.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the shorter one (c) neither (d) the later one
- 40.True or false: .card is an id selector. (a) False (b) True
Answer key
- on the right
- border
- black
- 60
- blue
- in the middle
- black
- p
- #main
- 60
- False
- blue
- shows a pop-up message
- 136
- <h2 class="menu">
- an element selector
- False
- 22
- 40
- blue
- equal gaps, none at ends
- HTML
- <p class="menu">
- 20
- color
- purple
- an element selector
- an element selector
- <p class="red">
- 32
- sets colours and fonts
- #00ff00
- 4
- gives the page structure
- Cascading Style Sheets
- black
- centres a heading
- makes letters bigger
- the later one
- False
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids