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.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 22px;
}
} (a) No (b) Yes - 2.📦 In the box model, which part is space inside the border? (a) border (b) margin (c) content (d) padding
-
3.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 190px;
padding: 5px;
border: 2px solid black;
margin: 5px;
} -
4.✍️ What is the selector in this CSS rule?
.note {
color: red;
font-weight: bold;
margin: 10px;
} (a) bold (b) .note (c) color (d) #top -
5.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 6px;
}
} (a) No (b) Yes - 6.True or false: li is an element selector. (a) False (b) True
- 7.📱 What does a media query check? (a) the page title (b) the battery level (c) the time of day (d) the screen width
-
8.✍️ What is the selector in this CSS rule?
p {
background-color: yellow;
margin: 10px;
font-weight: bold;
} (a) p (b) background-color (c) 10px (d) .note - 9.🌈 What is the biggest number one colour can have in rgb()? (a) 100 (b) 255 (c) 99 (d) 1000
- 10.✍️ Which sign ends each CSS declaration? (a) ; (b) : (c) . (d) ,
-
11.✍️ What value is given to font-size in this rule?
.box {
margin: 10px;
font-size: 20px;
border: 2px solid;
width: 300px;
} (a) yellow (b) font-size (c) 20px (d) center - 12.🌈 Which colour is rgb(255, 0, 0)? (a) cyan (b) bright green (c) yellow (d) red
- 13.✍️ In color: blue; which part is the value? (a) : (b) color (c) blue (d) ;
- 14.What does background-color do? (a) makes the text bold (b) makes letters bigger (c) colours behind the text (d) picks the font style
- 15.What does justify-content: center do? (a) equal gaps, none at ends (b) packs boxes at the end (c) puts boxes in the middle (d) packs boxes at the start
-
16.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 16px;
}
} - 17.🎨 Which tag connects an outside CSS file? (a) <css> (b) <a> (c) <img> (d) <link>
- 18.💪 Which justify-content value packs boxes at the start? (a) flex-end (b) space-between (c) center (d) flex-start
-
19.🖌️ What colour are the letters?
h1 {
text-align: center;
font-size: 12px;
color: red;
background-color: green;
} (a) green (b) red (c) orange -
20.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 140px;
justify-content: flex-start;
}
Inside are 3 boxes, each 40px wide (no margins). -
21.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 120px;
justify-content: space-between;
}
Inside are 2 boxes, each 40px wide (no margins). - 22.🌈 Which colour is #ffffff? (a) blue (b) white (c) red (d) cyan
- 23.True or false: JavaScript checks a quiz answer. (a) True (b) False
- 24.True or false: #top is an id selector. (a) True (b) False
- 25.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
-
26.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 180px;
padding: 15px;
border: 4px solid black;
margin: 0px;
} - 27.🎯 What kind of selector is .note? (a) an element selector (b) an id selector (c) a class selector
-
28.⚖️ What colour is the text of this element?
<h1 class="note" id="intro">Hi</h1>
CSS:
h1 { color: orange; }
.note { color: yellow; }
#intro { color: white; } (a) orange (b) white (c) red (d) yellow - 29.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the br tag (c) the hr tag (d) the viewport meta tag
- 30.🌈 Which hex code is yellow? (a) #ffff00 (b) #ffffff (c) #0000ff (d) #00ff00
-
31.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 120px;
padding: 10px;
border: 4px solid black;
margin: 5px;
} - 32.💪 Which justify-content value packs boxes at the end? (a) space-between (b) center (c) flex-end (d) flex-start
- 33.What does justify-content: space-between do? (a) packs boxes at the start (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the end
-
34.⚖️ What colour is the text of this element?
<h2 class="note" id="top">Hi</h2>
CSS:
.note { color: yellow; }
.note { color: black; } (a) orange (b) yellow (c) black (d) blue - 35.🌈 Which hex code is cyan? (a) #00ff00 (b) #00ffff (c) #0000ff (d) #ff0000
-
36.🖌️ Where does the text sit on its line?
p {
color: purple;
background-color: green;
font-size: 16px;
text-align: right;
} (a) on the left (b) in the middle (c) on the right -
37.🎯 Which CSS selector matches this element?
<div class="box" id="top">Hello</div> (a) #intro (b) div (c) span (d) .top -
38.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 6px;
}
} -
39.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 90px;
padding: 25px;
border: 2px solid black;
margin: 15px;
} -
40.⚖️ What colour is the text of this element?
<p class="red" id="main">Hi</p>
CSS:
p { color: yellow; }
#main { color: red; } (a) red (b) white (c) blue (d) yellow
Answer key
- Yes
- padding
- 214
- .note
- Yes
- True
- the screen width
- p
- 255
- ;
- 20px
- red
- blue
- colours behind the text
- puts boxes in the middle
- 20
- <link>
- flex-start
- red
- 20
- 40
- white
- True
- True
- an id selector
- 218
- a class selector
- white
- the viewport meta tag
- #ffff00
- 148
- flex-end
- equal gaps, none at ends
- black
- #00ffff
- on the right
- div
- 6
- 174
- red
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids