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 selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
- 2.📦 In the box model, which part is space inside the border? (a) border (b) padding (c) margin (d) content
-
3.✍️ Which property is set to 8px in this rule?
h2 {
font-weight: bold;
padding: 8px;
} (a) 8px (b) padding (c) font-weight (d) border - 4.🌈 In #rrggbb, which colour do the first two digits give? (a) black (b) red (c) blue (d) green
- 5.What does font-weight do? (a) picks the font style (b) makes the text bold (c) sets the letter colour (d) centres a heading
-
6.✍️ What is the selector in this CSS rule?
.box {
padding: 8px;
background-color: yellow;
text-align: center;
color: red;
} (a) yellow (b) .box (c) padding (d) h2 - 7.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) red (c) white (d) blue
- 8.What does justify-content: space-between do? (a) puts boxes in the middle (b) packs boxes at the end (c) packs boxes at the start (d) equal gaps, none at ends
-
9.⚖️ What colour is the text of this element?
<h1 class="star" id="end">Hi</h1>
CSS:
h1 { color: white; }
h1 { color: orange; } (a) orange (b) red (c) white (d) blue - 10.✍️ In color: blue; which part is the property? (a) ; (b) blue (c) : (d) color
- 11.🌈 Which colour is #ff00ff? (a) bright green (b) black (c) magenta (d) white
-
12.✍️ Which property is set to 20px in this rule?
li {
font-size: 20px;
font-style: italic;
} (a) font-size (b) background-color (c) text-align (d) 20px -
13.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 22px;
}
} (a) Yes (b) No - 14.What does background-color do? (a) centres a heading (b) colours behind the text (c) makes letters bigger (d) makes the text bold
- 15.🔍 Which is the odd one out? (a) makes headings and lists (b) puts a picture on a page (c) shows a pop-up message (d) gives the page structure
-
16.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 20px;
}
} -
17.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 250px;
justify-content: flex-start;
}
Inside are 3 boxes, each 80px wide (no margins). - 18.📦 In the box model, which part is the gap round content? (a) content (b) padding (c) border (d) margin
-
19.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 100px;
padding: 20px;
border: 2px solid black;
margin: 5px;
} - 20.True or false: margin is space outside the border. (a) True (b) False
- 21.🌈 Which colour is #000000? (a) black (b) yellow (c) red (d) bright green
- 22.True or false: HTML makes a form box. (a) True (b) False
-
23.🖌️ What colour is behind the letters?
li {
background-color: orange;
text-align: right;
font-size: 20px;
color: yellow;
} (a) blue (b) yellow (c) orange -
24.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 90px;
padding: 25px;
border: 1px solid black;
margin: 0px;
} - 25.🎯 Which sign starts an id selector? (a) & (b) . (c) @ (d) #
-
26.⚖️ What colour is the text of this element?
<h2 class="big" id="main">Hi</h2>
CSS:
.big { color: black; }
h2 { color: purple; }
#main { color: orange; } (a) yellow (b) black (c) orange (d) purple -
27.✍️ How many declarations (property: value pairs) are in this rule?
p {
background-color: yellow;
width: 300px;
} - 28.✍️ In color: blue; which part is the value? (a) : (b) ; (c) blue (d) color
- 29.True or false: #logo is a class selector. (a) False (b) True
-
30.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 14px;
}
} (a) Yes (b) No - 31.🎨 Which tag holds CSS inside the head? (a) <body> (b) <style> (c) <script> (d) <css>
- 32.💪 Which flexbox property sets space between boxes? (a) justify-content (b) gap (c) align-items (d) flex-direction
- 33.💪 Which justify-content value equal gaps, none at ends? (a) flex-end (b) space-between (c) center (d) flex-start
-
34.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 20px;
}
} (a) Yes (b) No - 35.🖌️ Which CSS property makes the text bold? (a) font-weight (b) font-family (c) text-align (d) color
- 36.🖌️ Which CSS property picks the font style? (a) color (b) background-color (c) font-weight (d) font-family
- 37.What does font-size do? (a) makes the text bold (b) centres a heading (c) picks the font style (d) makes letters bigger
- 38.What does justify-content: center do? (a) packs boxes at the end (b) packs boxes at the start (c) puts boxes in the middle (d) equal gaps, none at ends
- 39.🎯 Which sign starts a class selector? (a) . (b) # (c) @ (d) &
-
40.📦 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: 15px;
border: 1px solid black;
margin: 20px;
}
Answer key
- an id selector
- padding
- padding
- red
- makes the text bold
- .box
- blue
- equal gaps, none at ends
- orange
- color
- magenta
- font-size
- No
- colours behind the text
- shows a pop-up message
- 20
- 10
- padding
- 154
- True
- black
- True
- orange
- 142
- #
- orange
- 2
- blue
- False
- No
- <style>
- gap
- space-between
- No
- font-weight
- font-family
- makes letters bigger
- puts boxes in the middle
- .
- 182
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids