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.✍️ How many declarations (property: value pairs) are in this rule?
body {
font-size: 20px;
} - 2.🌈 Which hex code is blue? (a) #0000ff (b) #ffff00 (c) #000000 (d) #00ff00
- 3.🎨 A CSS file usually ends with which extension? (a) .png (b) .css (c) .html (d) .js
- 4.True or false: .star is an id selector. (a) False (b) True
-
5.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 18px;
}
} - 6.🌈 Which colour is rgb(0, 255, 0)? (a) magenta (b) bright green (c) white (d) blue
- 7.🎯 Can many elements share the same class? (a) No (b) Yes
-
8.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 18px;
}
} -
9.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 170px;
justify-content: flex-start;
}
Inside are 2 boxes, each 80px wide (no margins). - 10.🌈 Which hex code is yellow? (a) #ffffff (b) #ffff00 (c) #00ffff (d) #0000ff
- 11.🧩 Which language checks a quiz answer? (a) JavaScript (b) CSS (c) HTML
- 12.🎯 What kind of selector is .star? (a) a class selector (b) an id selector (c) an element selector
- 13.🎯 How many elements on a page should have the same id? (a) any number (b) 1 (c) 2 (d) 5
-
14.⚖️ What colour is the text of this element?
<p class="note" id="intro">Hi</p>
CSS:
#intro { color: purple; }
.note { color: red; }
p { color: white; } (a) orange (b) red (c) purple (d) white - 15.🎯 Which sign starts a class selector? (a) # (b) . (c) @ (d) &
- 16.What does justify-content: center do? (a) packs boxes at the start (b) packs boxes at the end (c) puts boxes in the middle (d) equal gaps, none at ends
-
17.🖌️ How big is the text, in px?
li {
color: yellow;
text-align: right;
font-size: 16px;
background-color: green;
} - 18.💪 Which flexbox property sets space between boxes? (a) justify-content (b) display: flex (c) align-items (d) gap
-
19.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 110px;
padding: 30px;
border: 1px solid black;
margin: 5px;
} - 20.🎯 What kind of selector is .card? (a) a class selector (b) an element selector (c) an id selector
- 21.🌈 Which colour is rgb(255, 0, 0)? (a) yellow (b) cyan (c) red (d) blue
-
22.🎯 Which CSS selector matches this element?
<p class="star" id="intro">Hello</p> (a) h1 (b) p (c) .intro (d) .menu -
23.✍️ What value is given to color in this rule?
h1 {
margin: 10px;
font-size: 20px;
font-style: italic;
color: red;
} (a) color (b) red (c) center (d) 20px -
24.✍️ What value is given to font-size in this rule?
.box {
font-size: 20px;
text-align: center;
padding: 8px;
} (a) center (b) yellow (c) 20px (d) font-size - 25.📦 In the box model, which part is a solid or dotted edge? (a) margin (b) content (c) border (d) padding
-
26.🎯 Which CSS selector matches this element?
<h2 class="star" id="intro">Hello</h2> (a) #star (b) .intro (c) .menu (d) .star - 27.🔍 Which is the odd one out? (a) makes headings and lists (b) makes a link (c) gives the page structure (d) rounds box corners
- 28.📱 What does a media query check? (a) the page title (b) the battery level (c) the screen width (d) the time of day
- 29.🌈 Which colour of light is strongest in rgb(214, 33, 110)? (a) green (b) red (c) blue
- 30.🖌️ Which CSS property sets the letter colour? (a) font-weight (b) color (c) font-size (d) text-align
-
31.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 480px) {
p {
font-size: 10px;
}
} (a) Yes (b) No -
32.✍️ What is the selector in this CSS rule?
li {
font-size: 20px;
font-weight: bold;
} (a) body (b) bold (c) li (d) font-size - 33.🌈 Which colour of light is strongest in rgb(36, 236, 114)? (a) green (b) blue (c) red
- 34.🌈 Which colour is rgb(255, 255, 255)? (a) red (b) white (c) cyan (d) blue
-
35.⚖️ What colour is the text of this element?
<h1 class="note" id="top">Hi</h1>
CSS:
#top { color: white; }
#top { color: purple; } (a) purple (b) white (c) black (d) yellow -
36.✍️ What is the selector in this CSS rule?
li {
font-size: 20px;
width: 300px;
font-style: italic;
margin: 10px;
} (a) body (b) li (c) font-size (d) 300px -
37.✍️ Which property is set to red in this rule?
h1 {
width: 300px;
font-size: 20px;
color: red;
} (a) font-size (b) text-align (c) red (d) color -
38.✍️ What is the selector in this CSS rule?
body {
font-style: italic;
background-color: yellow;
width: 300px;
} (a) .box (b) font-style (c) body (d) yellow - 39.🔍 Which is the odd one out? (a) makes a form box (b) puts a picture on a page (c) counts down a timer (d) makes a link
-
40.🖌️ Where does the text sit on its line?
li {
font-size: 16px;
background-color: black;
color: orange;
text-align: left;
} (a) in the middle (b) on the right (c) on the left
Answer key
- 1
- #0000ff
- .css
- False
- 12
- bright green
- Yes
- 18
- 10
- #ffff00
- JavaScript
- a class selector
- 1
- purple
- .
- puts boxes in the middle
- 16
- gap
- 182
- a class selector
- red
- p
- red
- 20px
- border
- .star
- rounds box corners
- the screen width
- red
- color
- No
- li
- green
- white
- purple
- li
- color
- body
- counts down a timer
- on the left
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids