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 CSS selector matches this element?
<span class="box" id="hero">Hello</span> (a) .hero (b) .star (c) span (d) #box - 2.🔍 Which is the odd one out? (a) checks a quiz answer (b) reacts to a button click (c) shows a pop-up message (d) changes the text size
-
3.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 240px;
justify-content: center;
}
Inside are 2 boxes, each 60px wide (no margins). - 4.✍️ CSS declarations go inside which brackets? (a) ( ) (b) < > (c) { } (d) [ ]
- 5.True or false: .menu is an id selector. (a) False (b) True
- 6.🌈 Which colour is #00ff00? (a) yellow (b) red (c) magenta (d) bright green
- 7.💪 Which justify-content value packs boxes at the start? (a) space-between (b) center (c) flex-start (d) flex-end
- 8.True or false: CSS makes a link. (a) False (b) True
- 9.True or false: the content is the gap round content. (a) False (b) True
- 10.What does font-family do? (a) makes the text bold (b) picks the font style (c) centres a heading (d) colours behind the text
-
11.✍️ Which property is set to 10px in this rule?
.box {
margin: 10px;
width: 300px;
} (a) font-weight (b) margin (c) padding (d) 10px - 12.🎯 Which sign starts a class selector? (a) . (b) & (c) @ (d) #
- 13.💪 Which justify-content value puts boxes in the middle? (a) space-between (b) flex-start (c) center (d) flex-end
-
14.✍️ What value is given to border in this rule?
body {
font-weight: bold;
font-style: italic;
border: 2px solid;
width: 300px;
} (a) 300px (b) border (c) italic (d) 2px solid - 15.💪 Which justify-content value equal gaps, none at ends? (a) center (b) flex-end (c) space-between (d) flex-start
-
16.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 220px;
justify-content: space-between;
}
Inside are 3 boxes, each 60px wide (no margins). -
17.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 150px;
padding: 5px;
border: 1px solid black;
margin: 0px;
} - 18.🌈 Which hex code is red? (a) #ffff00 (b) #000000 (c) #ff0000 (d) #0000ff
- 19.📦 In the box model, which part is a solid or dotted edge? (a) content (b) margin (c) border (d) padding
-
20.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 220px;
justify-content: flex-start;
}
Inside are 4 boxes, each 40px wide (no margins). - 21.🎯 What kind of selector is img? (a) an id selector (b) a class selector (c) an element selector
- 22.📱 Which tag helps phones show a page at the right size? (a) the viewport meta tag (b) the br tag (c) the hr tag (d) the title tag
-
23.⚖️ What colour is the text of this element?
<p class="star" id="hero">Hi</p>
CSS:
p { color: purple; }
p { color: red; } (a) orange (b) red (c) green (d) purple - 24.🌈 Which colour of light is strongest in rgb(180, 54, 14)? (a) blue (b) green (c) red
-
25.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 280px;
padding: 30px;
border: 2px solid black;
margin: 15px;
} -
26.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 270px;
justify-content: space-between;
}
Inside are 2 boxes, each 100px wide (no margins). - 27.True or false: body is an id selector. (a) True (b) False
-
28.✍️ What is the selector in this CSS rule?
body {
border: 2px solid;
font-size: 20px;
margin: 10px;
} (a) border (b) body (c) 20px (d) .box - 29.🧩 Which language gives the page structure? (a) CSS (b) HTML (c) JavaScript
-
30.🖌️ How big is the text, in px?
p {
background-color: red;
color: white;
text-align: right;
font-size: 28px;
} - 31.🖌️ Which CSS property makes the text bold? (a) color (b) font-weight (c) background-color (d) font-size
-
32.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} - 33.🌈 Which colour is #ff0000? (a) red (b) yellow (c) black (d) white
- 34.🖌️ Which CSS property sets the letter colour? (a) font-family (b) font-size (c) font-weight (d) color
- 35.What does background-color do? (a) makes letters bigger (b) picks the font style (c) makes the text bold (d) colours behind the text
-
36.🖌️ How big is the text, in px?
p {
background-color: orange;
font-size: 40px;
color: yellow;
text-align: center;
} - 37.🌈 Which colour of light is strongest in rgb(16, 114, 242)? (a) green (b) blue (c) red
- 38.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
-
39.🖌️ What colour are the letters?
p {
text-align: center;
color: green;
background-color: red;
font-size: 28px;
} (a) red (b) green (c) blue -
40.✍️ How many declarations (property: value pairs) are in this rule?
.box {
font-size: 20px;
color: red;
padding: 8px;
text-align: center;
}
Answer key
- span
- changes the text size
- 60
- { }
- False
- bright green
- flex-start
- False
- False
- picks the font style
- margin
- .
- center
- 2px solid
- space-between
- 20
- 162
- #ff0000
- border
- 60
- an element selector
- the viewport meta tag
- red
- red
- 374
- 70
- False
- body
- HTML
- 28
- font-weight
- 20
- red
- color
- colours behind the text
- 40
- blue
- an element selector
- green
- 4
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids