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 much empty space (px) is before the first box?
.row {
display: flex;
width: 240px;
justify-content: flex-end;
}
Inside are 4 boxes, each 50px wide (no margins). -
2.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 14px;
}
} (a) No (b) Yes -
3.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 18px;
}
} - 4.🎨 A CSS file usually ends with which extension? (a) .html (b) .css (c) .js (d) .png
-
5.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 16px;
}
} (a) Yes (b) No - 6.What does font-size do? (a) makes letters bigger (b) sets the letter colour (c) picks the font style (d) makes the text bold
- 7.🌈 Which hex code is blue? (a) #ffff00 (b) #ff00ff (c) #ff0000 (d) #0000ff
-
8.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 16px;
}
} -
9.⚖️ What colour is the text of this element?
<h2 class="star" id="top">Hi</h2>
CSS:
#top { color: orange; }
h2 { color: green; } (a) red (b) white (c) orange (d) green - 10.🖌️ Which CSS property makes letters bigger? (a) font-size (b) text-align (c) font-family (d) color
- 11.True or false: padding is the gap to other boxes. (a) False (b) True
- 12.🎯 Which sign starts a class selector? (a) @ (b) . (c) # (d) &
-
13.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 18px;
}
} -
14.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 6px;
}
} - 15.True or false: body is an element selector. (a) True (b) False
- 16.What does justify-content: center do? (a) packs boxes at the end (b) puts boxes in the middle (c) packs boxes at the start (d) equal gaps, none at ends
-
17.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 120px;
justify-content: center;
}
Inside are 2 boxes, each 40px wide (no margins). - 18.What does justify-content: space-between do? (a) packs boxes at the start (b) equal gaps, none at ends (c) packs boxes at the end (d) puts boxes in the middle
- 19.🖌️ Which CSS property sets the letter colour? (a) text-align (b) font-weight (c) font-family (d) color
- 20.🖌️ Which CSS property picks the font style? (a) font-family (b) text-align (c) background-color (d) color
- 21.🔍 Which is the odd one out? (a) makes headings and lists (b) rounds box corners (c) puts a picture on a page (d) gives the page structure
- 22.🎯 Which element does the selector .star style? (a) <h2 class="star"> (b) <h2 id="star"> (c) <h2 class="menu"> (d) <li class="note">
-
23.⚖️ What colour is the text of this element?
<h2 class="big" id="main">Hi</h2>
CSS:
#main { color: yellow; }
.big { color: green; } (a) green (b) yellow (c) white (d) black -
24.✍️ What value is given to font-weight in this rule?
p {
font-size: 20px;
font-weight: bold;
} (a) font-weight (b) 300px (c) 2px solid (d) bold -
25.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 70px;
padding: 30px;
border: 1px solid black;
margin: 0px;
} -
26.⚖️ What colour is the text of this element?
<p class="menu" id="intro">Hi</p>
CSS:
#intro { color: yellow; }
#intro { color: purple; } (a) purple (b) yellow (c) blue (d) green - 27.📦 In the box model, which part is a solid or dotted edge? (a) content (b) margin (c) padding (d) border
-
28.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 1024px) {
p {
font-size: 18px;
}
} (a) No (b) Yes -
29.🖌️ How big is the text, in px?
li {
font-size: 32px;
background-color: yellow;
text-align: left;
color: red;
} -
30.🖌️ Where does the text sit on its line?
p {
background-color: green;
font-size: 40px;
text-align: right;
color: yellow;
} (a) on the left (b) in the middle (c) on the right -
31.✍️ Which property is set to red in this rule?
body {
margin: 10px;
padding: 8px;
width: 300px;
color: red;
} (a) text-align (b) font-size (c) red (d) color - 32.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the shorter one (c) the later one (d) neither
-
33.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 8px;
}
} (a) Yes (b) No - 34.🌈 Hex digits go 0 to 9, then A to which letter? (a) Z (b) F (c) J (d) G
- 35.🎯 Can many elements share the same class? (a) No (b) Yes
- 36.✍️ In color: blue; which part is the property? (a) ; (b) color (c) : (d) blue
-
37.🎯 Which CSS selector matches this element?
<span class="box" id="intro">Hello</span> (a) .star (b) .box (c) .intro (d) #box - 38.✍️ Which sign goes between a property and its value? (a) - (b) = (c) ; (d) :
-
39.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
width: 300px;
text-align: center;
} -
40.✍️ Which property is set to center in this rule?
#top {
font-size: 20px;
text-align: center;
} (a) margin (b) background-color (c) center (d) text-align
Answer key
- 40
- No
- 18
- .css
- Yes
- makes letters bigger
- #0000ff
- 12
- orange
- font-size
- False
- .
- 18
- 6
- True
- puts boxes in the middle
- 20
- equal gaps, none at ends
- color
- font-family
- rounds box corners
- <h2 class="star">
- yellow
- bold
- 132
- purple
- border
- Yes
- 32
- on the right
- color
- the later one
- Yes
- F
- Yes
- color
- .box
- :
- 2
- text-align
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids