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?
p {
color: yellow;
text-align: center;
background-color: green;
font-size: 20px;
} (a) on the right (b) in the middle (c) on the left - 2.🌈 Which colour is #00ff00? (a) red (b) bright green (c) magenta (d) blue
- 3.True or false: .menu is an id selector. (a) True (b) False
- 4.What does font-family do? (a) colours behind the text (b) picks the font style (c) centres a heading (d) makes letters bigger
- 5.True or false: JavaScript adds space around boxes. (a) False (b) True
- 6.🎯 What kind of selector is h1? (a) an element selector (b) a class selector (c) an id selector
-
7.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 240px;
justify-content: flex-end;
}
Inside are 2 boxes, each 80px wide (no margins). -
8.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 140px;
justify-content: space-between;
}
Inside are 2 boxes, each 40px wide (no margins). -
9.✍️ How many declarations (property: value pairs) are in this rule?
.note {
width: 300px;
background-color: yellow;
border: 2px solid;
padding: 8px;
} -
10.🎯 Which CSS selector matches this element?
<p class="menu" id="hero">Hello</p> (a) #menu (b) h1 (c) .hero (d) p - 11.True or false: margin is the text or picture. (a) True (b) False
- 12.🧩 Which language makes a link? (a) JavaScript (b) CSS (c) HTML
- 13.🌈 Which colour is #ffffff? (a) blue (b) magenta (c) red (d) white
-
14.⚖️ What colour is the text of this element?
<p class="big" id="intro">Hi</p>
CSS:
.big { color: red; }
#intro { color: black; }
p { color: yellow; } (a) yellow (b) purple (c) black (d) red - 15.🔍 Which is the odd one out? (a) gives the page structure (b) adds space around boxes (c) changes the text size (d) sets colours and fonts
- 16.💪 Which justify-content value packs boxes at the end? (a) center (b) flex-start (c) space-between (d) flex-end
-
17.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 32px;
}
} (a) Yes (b) No -
18.✍️ What is the selector in this CSS rule?
.box {
font-weight: bold;
font-size: 20px;
} (a) font-weight (b) h2 (c) 20px (d) .box - 19.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
-
20.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 60px;
padding: 15px;
border: 1px solid black;
margin: 5px;
} - 21.💪 Which flexbox property sets space between boxes? (a) display: flex (b) gap (c) flex-direction (d) justify-content
- 22.✍️ Which sign ends each CSS declaration? (a) : (b) . (c) ; (d) ,
-
23.✍️ What is the selector in this CSS rule?
body {
text-align: center;
margin: 10px;
font-style: italic;
background-color: yellow;
} (a) .box (b) body (c) text-align (d) 10px -
24.⚖️ What colour is the text of this element?
<p class="red" id="top">Hi</p>
CSS:
.red { color: black; }
#top { color: white; } (a) black (b) green (c) white (d) blue - 25.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
-
26.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 20px;
}
} (a) Yes (b) No - 27.✍️ Which sign goes between a property and its value? (a) ; (b) = (c) : (d) -
- 28.🖌️ Which CSS property sets the letter colour? (a) background-color (b) color (c) font-weight (d) font-size
- 29.What does background-color do? (a) centres a heading (b) sets the letter colour (c) colours behind the text (d) picks the font style
- 30.🎨 Which tag connects an outside CSS file? (a) <a> (b) <img> (c) <css> (d) <link>
- 31.🎨 Which tag holds CSS inside the head? (a) <body> (b) <script> (c) <css> (d) <style>
- 32.🎨 What does CSS stand for? (a) Computer Style Sheets (b) Colourful Site Styles (c) Creative Sheet System (d) Cascading Style Sheets
-
33.🖌️ What colour is behind the letters?
h2 {
color: red;
font-size: 24px;
text-align: center;
background-color: yellow;
} (a) blue (b) red (c) yellow -
34.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 10px;
}
} -
35.🎯 Which CSS selector matches this element?
<p class="red" id="logo">Hello</p> (a) .box (b) p (c) h1 (d) .logo -
36.🖌️ Where does the text sit on its line?
h2 {
text-align: left;
color: purple;
background-color: blue;
font-size: 40px;
} (a) in the middle (b) on the left (c) on the right - 37.🌈 Which colour of light is strongest in rgb(46, 156, 16)? (a) red (b) green (c) blue
-
38.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 340px;
justify-content: flex-end;
}
Inside are 4 boxes, each 80px wide (no margins). - 39.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) neither (c) the shorter one (d) the later one
-
40.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 3 boxes, each 80px wide (no margins).
Answer key
- in the middle
- bright green
- False
- picks the font style
- False
- an element selector
- 80
- 60
- 4
- p
- False
- HTML
- white
- black
- gives the page structure
- flex-end
- No
- .box
- an id selector
- 102
- gap
- ;
- body
- white
- an element selector
- No
- :
- color
- colours behind the text
- <link>
- <style>
- Cascading Style Sheets
- yellow
- 10
- p
- on the left
- green
- 20
- the later one
- 10
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids