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.What does font-size do? (a) centres a heading (b) colours behind the text (c) sets the letter colour (d) makes letters bigger
-
2.🖌️ Where does the text sit on its line?
h2 {
font-size: 24px;
text-align: left;
color: white;
background-color: blue;
} (a) in the middle (b) on the left (c) on the right - 3.🌈 Which hex code is blue? (a) #0000ff (b) #ffff00 (c) #ffffff (d) #00ffff
-
4.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 8px;
}
} -
5.⚖️ What colour is the text of this element?
<h2 class="red" id="main">Hi</h2>
CSS:
.red { color: red; }
.red { color: yellow; } (a) yellow (b) white (c) orange (d) red -
6.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 260px;
padding: 25px;
border: 4px solid black;
margin: 15px;
} - 7.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
- 8.What does justify-content: center do? (a) equal gaps, none at ends (b) packs boxes at the end (c) packs boxes at the start (d) puts boxes in the middle
-
9.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 10px;
}
} - 10.✍️ CSS declarations go inside which brackets? (a) { } (b) < > (c) ( ) (d) [ ]
- 11.🎯 What kind of selector is .big? (a) a class selector (b) an element selector (c) an id selector
-
12.✍️ What is the selector in this CSS rule?
li {
text-align: center;
border: 2px solid;
font-size: 20px;
background-color: yellow;
} (a) li (b) body (c) 2px solid (d) text-align - 13.🔍 Which is the odd one out? (a) puts a picture on a page (b) adds space around boxes (c) rounds box corners (d) sets colours and fonts
-
14.✍️ What value is given to font-size in this rule?
li {
border: 2px solid;
padding: 8px;
font-style: italic;
font-size: 20px;
} (a) font-size (b) center (c) yellow (d) 20px - 15.🖌️ Which CSS property colours behind the text? (a) text-align (b) font-weight (c) font-size (d) background-color
-
16.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 28px;
}
} (a) Yes (b) No -
17.⚖️ What colour is the text of this element?
<p class="note" id="hero">Hi</p>
CSS:
p { color: purple; }
#hero { color: black; } (a) blue (b) black (c) orange (d) purple -
18.✍️ What value is given to color in this rule?
body {
text-align: center;
font-size: 20px;
color: red;
} (a) 20px (b) center (c) color (d) red -
19.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 22px;
}
} (a) No (b) Yes - 20.🌈 Which hex code is red? (a) #00ff00 (b) #000000 (c) #ff00ff (d) #ff0000
- 21.True or false: CSS gives the page structure. (a) True (b) False
-
22.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 210px;
justify-content: flex-end;
}
Inside are 2 boxes, each 100px wide (no margins). -
23.🎯 Which CSS selector matches this element?
<p class="box" id="hero">Hello</p> (a) #box (b) #top (c) .hero (d) p -
24.🖌️ How big is the text, in px?
h2 {
background-color: blue;
color: yellow;
font-size: 36px;
text-align: right;
} - 25.🖌️ Which CSS property sets the letter colour? (a) font-size (b) font-family (c) font-weight (d) color
- 26.What does justify-content: flex-start 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
- 27.Which of these does CSS do? (a) shows a pop-up message (b) checks a quiz answer (c) makes a form box (d) rounds box corners
-
28.✍️ What value is given to font-style in this rule?
#top {
font-style: italic;
background-color: yellow;
width: 300px;
} (a) font-style (b) 20px (c) italic (d) red - 29.🖌️ Which CSS property makes letters bigger? (a) font-weight (b) background-color (c) font-family (d) font-size
- 30.True or false: CSS shows a pop-up message. (a) False (b) True
-
31.⚖️ What colour is the text of this element?
<h1 class="star" id="main">Hi</h1>
CSS:
#main { color: black; }
#main { color: purple; } (a) purple (b) black (c) white (d) yellow -
32.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 20px;
}
} - 33.Which of these is the content? (a) a solid or dotted edge (b) the text or picture (c) the line round the box (d) the gap to other boxes
- 34.Which of these does CSS do? (a) changes the page live (b) counts down a timer (c) adds space around boxes (d) shows a pop-up message
-
35.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 18px;
}
} (a) Yes (b) No -
36.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} (a) No (b) Yes - 37.True or false: #end is a class selector. (a) True (b) False
-
38.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 768px) {
p {
font-size: 12px;
}
} (a) Yes (b) No -
39.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 32px;
}
} (a) No (b) Yes -
40.✍️ What value is given to border in this rule?
.note {
border: 2px solid;
padding: 8px;
} (a) 2px solid (b) border (c) italic (d) 300px
Answer key
- makes letters bigger
- on the left
- #0000ff
- 12
- yellow
- 348
- an element selector
- puts boxes in the middle
- 10
- { }
- a class selector
- li
- puts a picture on a page
- 20px
- background-color
- Yes
- black
- red
- No
- #ff0000
- False
- 10
- p
- 36
- color
- packs boxes at the start
- rounds box corners
- italic
- font-size
- False
- purple
- 12
- the text or picture
- adds space around boxes
- Yes
- Yes
- False
- Yes
- Yes
- 2px solid
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids