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 1100px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 28px;
}
} (a) Yes (b) No -
2.🖌️ What colour is behind the letters?
li {
background-color: green;
color: purple;
text-align: center;
font-size: 40px;
} (a) green (b) purple (c) orange -
3.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 70px;
padding: 30px;
border: 1px solid black;
margin: 0px;
} - 4.🔍 Which is the odd one out? (a) makes a link (b) puts a picture on a page (c) makes a form box (d) changes the text size
- 5.🖌️ Which CSS property picks the font style? (a) color (b) background-color (c) font-family (d) font-weight
- 6.💪 Which justify-content value equal gaps, none at ends? (a) space-between (b) flex-start (c) flex-end (d) center
- 7.🎯 Which element does the selector #end style? (a) <span class="red"> (b) <div id="hero"> (c) <div class="end"> (d) <div id="end">
-
8.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 300px;
justify-content: center;
}
Inside are 4 boxes, each 50px wide (no margins). -
9.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 14px;
}
} (a) Yes (b) No -
10.🖌️ Where does the text sit on its line?
p {
color: yellow;
text-align: right;
background-color: blue;
font-size: 32px;
} (a) in the middle (b) on the left (c) on the right -
11.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 32px;
}
} (a) No (b) Yes -
12.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 260px;
justify-content: space-between;
}
Inside are 4 boxes, each 50px wide (no margins). -
13.⚖️ What colour is the text of this element?
<p class="star" id="main">Hi</p>
CSS:
p { color: white; }
#main { color: purple; }
.star { color: red; } (a) orange (b) purple (c) white (d) red - 14.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
-
15.🖌️ What colour is behind the letters?
h2 {
color: red;
font-size: 40px;
background-color: black;
text-align: left;
} (a) red (b) purple (c) black - 16.🖌️ Which CSS property sets the letter colour? (a) font-size (b) color (c) text-align (d) font-weight
-
17.💪 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 50px wide (no margins). - 18.True or false: JavaScript adds space around boxes. (a) False (b) True
- 19.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) exactly 100px (c) turned off (d) 800px or wider
- 20.🧩 Which language lays out the page? (a) JavaScript (b) CSS (c) HTML
-
21.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 18px;
}
} - 22.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) blue (c) black (d) red
-
23.⚖️ What colour is the text of this element?
<p class="star" id="top">Hi</p>
CSS:
p { color: green; }
p { color: white; } (a) blue (b) green (c) red (d) white -
24.✍️ What is the selector in this CSS rule?
.note {
background-color: yellow;
color: red;
border: 2px solid;
} (a) #top (b) .note (c) background-color (d) red - 25.✍️ CSS declarations go inside which brackets? (a) ( ) (b) { } (c) [ ] (d) < >
- 26.Which of these does HTML do? (a) changes the text size (b) sets colours and fonts (c) puts a picture on a page (d) checks a quiz answer
- 27.What does justify-content: center 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
- 28.✍️ In color: blue; which part is the value? (a) : (b) ; (c) blue (d) color
- 29.🎯 Which element does the selector h2 style? (a) <div class="big"> (b) <li> (c) <span id="top"> (d) <h2 class="big">
- 30.🌈 Which colour is #0000ff? (a) yellow (b) white (c) blue (d) cyan
- 31.🎯 Can many elements share the same class? (a) No (b) Yes
-
32.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 160px;
justify-content: flex-start;
}
Inside are 2 boxes, each 40px wide (no margins). -
33.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 12px;
}
} - 34.🎯 Which element does the selector .menu style? (a) <div class="big"> (b) <li class="menu"> (c) <li id="menu"> (d) <li class="note">
- 35.🌈 Which colour is rgb(255, 255, 255)? (a) bright green (b) red (c) magenta (d) white
-
36.✍️ How many declarations (property: value pairs) are in this rule?
li {
color: red;
font-size: 20px;
} - 37.📱 What does a media query check? (a) the battery level (b) the time of day (c) the screen width (d) the page title
-
38.✍️ What is the selector in this CSS rule?
body {
background-color: yellow;
color: red;
border: 2px solid;
font-size: 20px;
} (a) background-color (b) body (c) red (d) .box - 39.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
- 40.📦 In the box model, which part is a solid or dotted edge? (a) margin (b) content (c) border (d) padding
Answer key
- Yes
- green
- 132
- changes the text size
- font-family
- space-between
- <div id="end">
- 50
- No
- on the right
- Yes
- 20
- purple
- an element selector
- black
- color
- 20
- False
- 800px or wider
- CSS
- 16
- red
- white
- .note
- { }
- puts a picture on a page
- puts boxes in the middle
- blue
- <h2 class="big">
- blue
- Yes
- 80
- 16
- <li class="menu">
- white
- 2
- the screen width
- body
- an id selector
- border
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids