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.🌈 In #rrggbb, which colour do the last two digits give? (a) white (b) red (c) blue (d) green
- 2.💪 Which flexbox property spaces boxes along a row? (a) gap (b) display: flex (c) flex-direction (d) justify-content
- 3.🌈 Which colour is rgb(255, 0, 255)? (a) blue (b) bright green (c) black (d) magenta
- 4.✍️ Which sign ends each CSS declaration? (a) : (b) . (c) ; (d) ,
- 5.🧩 Which language reacts to a button click? (a) HTML (b) CSS (c) JavaScript
-
6.⚖️ What colour is the text of this element?
<h2 class="big" id="main">Hi</h2>
CSS:
.big { color: purple; }
h2 { color: blue; }
#main { color: white; } (a) white (b) blue (c) orange (d) purple -
7.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 120px;
padding: 30px;
border: 2px solid black;
margin: 15px;
} -
8.✍️ What value is given to text-align in this rule?
p {
text-align: center;
font-size: 20px;
font-style: italic;
} (a) yellow (b) 10px (c) center (d) text-align -
9.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 170px;
padding: 20px;
border: 2px solid black;
margin: 10px;
} -
10.⚖️ What colour is the text of this element?
<p class="note" id="hero">Hi</p>
CSS:
#hero { color: white; }
#hero { color: orange; } (a) yellow (b) white (c) green (d) orange -
11.🖌️ What colour is behind the letters?
h1 {
background-color: red;
font-size: 24px;
color: blue;
text-align: left;
} (a) blue (b) orange (c) red -
12.🎯 Which CSS selector matches this element?
<p class="red" id="logo">Hello</p> (a) .logo (b) h1 (c) #end (d) p -
13.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 120px;
justify-content: flex-end;
}
Inside are 2 boxes, each 40px wide (no margins). - 14.✍️ CSS declarations go inside which brackets? (a) < > (b) ( ) (c) { } (d) [ ]
- 15.💪 Which flexbox property lines boxes up across? (a) flex-direction (b) display: flex (c) justify-content (d) align-items
-
16.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 6px;
}
} (a) Yes (b) No - 17.🌈 Which colour of light is strongest in rgb(22, 78, 153)? (a) green (b) red (c) blue
- 18.✍️ How does a CSS comment start? (a) // (b) <!-- (c) /* (d) #
-
19.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 30px;
}
} - 20.💪 Which justify-content value packs boxes at the end? (a) flex-start (b) flex-end (c) space-between (d) center
-
21.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 110px;
padding: 5px;
border: 3px solid black;
margin: 5px;
} - 22.💪 Which justify-content value packs boxes at the start? (a) space-between (b) flex-end (c) center (d) flex-start
-
23.🖌️ How big is the text, in px?
h2 {
font-size: 20px;
text-align: center;
color: yellow;
background-color: red;
} -
24.🎯 Which CSS selector matches this element?
<p class="box" id="end">Hello</p> (a) .end (b) #hero (c) h1 (d) #end - 25.🎯 Which sign starts an id selector? (a) . (b) @ (c) & (d) #
- 26.What does justify-content: flex-start do? (a) puts boxes in the middle (b) packs boxes at the start (c) packs boxes at the end (d) equal gaps, none at ends
-
27.✍️ Which property is set to 300px in this rule?
h2 {
background-color: yellow;
color: red;
font-size: 20px;
width: 300px;
} (a) font-style (b) 300px (c) color (d) width - 28.📱 What does a media query check? (a) the time of day (b) the screen width (c) the page title (d) the battery level
-
29.✍️ What value is given to font-weight in this rule?
h2 {
font-weight: bold;
margin: 10px;
} (a) 2px solid (b) 300px (c) bold (d) font-weight - 30.🌈 Which colour of light is strongest in rgb(150, 108, 17)? (a) blue (b) green (c) red
-
31.🖌️ How big is the text, in px?
h2 {
color: green;
background-color: purple;
font-size: 36px;
text-align: right;
} -
32.🖌️ Where does the text sit on its line?
li {
text-align: left;
background-color: black;
font-size: 28px;
color: red;
} (a) on the right (b) in the middle (c) on the left - 33.🌈 Which colour is #ff00ff? (a) red (b) black (c) magenta (d) blue
-
34.⚖️ What colour is the text of this element?
<h1 class="red" id="top">Hi</h1>
CSS:
h1 { color: red; }
#top { color: purple; }
.red { color: black; } (a) purple (b) red (c) yellow (d) black -
35.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 460px;
justify-content: center;
}
Inside are 4 boxes, each 100px wide (no margins). - 36.🌈 Which colour is #ffffff? (a) cyan (b) black (c) white (d) bright green
-
37.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 130px;
justify-content: flex-start;
}
Inside are 2 boxes, each 50px wide (no margins). - 38.🎯 How many elements on a page should have the same id? (a) 2 (b) any number (c) 1 (d) 5
-
39.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 768px) {
p {
font-size: 28px;
}
} - 40.💪 Which justify-content value puts boxes in the middle? (a) flex-end (b) flex-start (c) space-between (d) center
Answer key
- blue
- justify-content
- magenta
- ;
- JavaScript
- white
- 214
- center
- 214
- orange
- red
- p
- 40
- { }
- align-items
- Yes
- blue
- /*
- 30
- flex-end
- 136
- flex-start
- 20
- #end
- #
- packs boxes at the start
- width
- the screen width
- bold
- red
- 36
- on the left
- magenta
- purple
- 30
- white
- 30
- 1
- 24
- center
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids