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 left after the last box?
.row {
display: flex;
width: 430px;
justify-content: flex-start;
}
Inside are 4 boxes, each 100px wide (no margins). - 2.📱 Which tag helps phones show a page at the right size? (a) the viewport meta tag (b) the title tag (c) the hr tag (d) the br tag
-
3.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 440px;
justify-content: flex-start;
}
Inside are 4 boxes, each 100px wide (no margins). -
4.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
font-weight: bold;
background-color: yellow;
} - 5.🎨 A CSS file usually ends with which extension? (a) .css (b) .js (c) .html (d) .png
-
6.🎯 Which CSS selector matches this element?
<p class="box" id="hero">Hello</p> (a) #box (b) .hero (c) .star (d) p -
7.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 190px;
padding: 5px;
border: 3px solid black;
margin: 0px;
} - 8.What does justify-content: space-between do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the end (d) packs boxes at the start
- 9.What does justify-content: flex-start do? (a) puts boxes in the middle (b) equal gaps, none at ends (c) packs boxes at the end (d) packs boxes at the start
- 10.✍️ Which sign ends each CSS declaration? (a) , (b) . (c) ; (d) :
- 11.💪 Which flexbox property turns on flexbox? (a) gap (b) justify-content (c) align-items (d) display: flex
- 12.🌈 In #0000b4 the blue part is the hex number b4. What is it as a normal number?
- 13.📱 What does a media query check? (a) the battery level (b) the page title (c) the screen width (d) the time of day
-
14.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 1024px) {
p {
font-size: 22px;
}
} -
15.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 100px;
padding: 20px;
border: 3px solid black;
margin: 0px;
} - 16.True or false: padding is the gap round content. (a) False (b) True
-
17.⚖️ What colour is the text of this element?
<h1 class="big" id="top">Hi</h1>
CSS:
.big { color: yellow; }
#top { color: red; } (a) purple (b) yellow (c) blue (d) red - 18.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the shorter one (c) the later one (d) the first one
- 19.🔍 Which is the odd one out? (a) adds space around boxes (b) counts down a timer (c) shows a pop-up message (d) checks a quiz answer
-
20.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 300px;
padding: 5px;
border: 2px solid black;
margin: 15px;
} - 21.True or false: body is a class selector. (a) True (b) False
-
22.🎯 Which CSS selector matches this element?
<h2 class="big" id="end">Hello</h2> (a) .red (b) li (c) #big (d) .big - 23.🌈 Which colour is #00ff00? (a) black (b) bright green (c) white (d) magenta
- 24.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) 800px or narrower (c) exactly 100px (d) 800px or wider
-
25.✍️ Which property is set to 2px solid in this rule?
p {
text-align: center;
margin: 10px;
border: 2px solid;
font-style: italic;
} (a) 2px solid (b) width (c) border (d) font-style - 26.🎯 How many elements on a page should have the same id? (a) 1 (b) any number (c) 2 (d) 5
-
27.⚖️ What colour is the text of this element?
<h2 class="star" id="hero">Hi</h2>
CSS:
h2 { color: purple; }
.star { color: green; } (a) yellow (b) green (c) black (d) purple -
28.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 160px;
justify-content: space-between;
}
Inside are 3 boxes, each 40px wide (no margins). - 29.🌈 In #d80000 the red part is the hex number d8. What is it as a normal number?
- 30.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 2 (b) 3 (c) 6 (d) 4
-
31.⚖️ What colour is the text of this element?
<h2 class="box" id="hero">Hi</h2>
CSS:
#hero { color: green; }
#hero { color: black; } (a) green (b) white (c) purple (d) black - 32.💪 Which flexbox property sets space between boxes? (a) flex-direction (b) gap (c) justify-content (d) display: flex
- 33.🌈 Which colour is #ffff00? (a) yellow (b) red (c) magenta (d) bright green
- 34.✍️ How does a CSS comment start? (a) /* (b) // (c) <!-- (d) #
- 35.💪 Which flexbox property picks row or column? (a) flex-direction (b) gap (c) display: flex (d) align-items
- 36.🧩 Which language rounds box corners? (a) JavaScript (b) CSS (c) HTML
-
37.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 320px;
justify-content: flex-start;
}
Inside are 3 boxes, each 100px wide (no margins). - 38.🔍 Which is the odd one out? (a) lays out the page (b) changes the text size (c) sets colours and fonts (d) checks a quiz answer
-
39.🖌️ What colour are the letters?
li {
background-color: orange;
color: blue;
font-size: 36px;
text-align: center;
} (a) orange (b) white (c) blue -
40.✍️ What value is given to background-color in this rule?
li {
padding: 8px;
background-color: yellow;
text-align: center;
} (a) yellow (b) background-color (c) 10px (d) 8px
Answer key
- 30
- the viewport meta tag
- 40
- 2
- .css
- p
- 206
- equal gaps, none at ends
- packs boxes at the start
- ;
- display: flex
- 180
- the screen width
- 20
- 146
- True
- red
- the later one
- adds space around boxes
- 344
- False
- .big
- bright green
- 800px or wider
- border
- 1
- green
- 20
- 216
- 3
- black
- gap
- yellow
- /*
- flex-direction
- CSS
- 20
- checks a quiz answer
- blue
- yellow
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids