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 820px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 1024px) {
p {
font-size: 26px;
}
} (a) Yes (b) No - 2.🖌️ Which CSS property colours behind the text? (a) font-family (b) font-weight (c) color (d) background-color
- 3.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the first one (c) the later one (d) the shorter one
-
4.✍️ How many declarations (property: value pairs) are in this rule?
li {
border: 2px solid;
color: red;
} - 5.💪 Which flexbox property spaces boxes along a row? (a) gap (b) display: flex (c) justify-content (d) flex-direction
-
6.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 280px;
justify-content: space-between;
}
Inside are 3 boxes, each 60px wide (no margins). -
7.✍️ How many declarations (property: value pairs) are in this rule?
p {
text-align: center;
color: red;
} - 8.True or false: margin is space inside the border. (a) False (b) True
- 9.🔍 Which is the odd one out? (a) gives the page structure (b) makes a link (c) changes the page live (d) makes a form box
- 10.📦 In the box model, which part is a solid or dotted edge? (a) padding (b) margin (c) content (d) border
-
11.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 260px;
justify-content: flex-start;
}
Inside are 3 boxes, each 60px wide (no margins). -
12.🖌️ Where does the text sit on its line?
h2 {
text-align: right;
font-size: 40px;
color: orange;
background-color: black;
} (a) on the left (b) in the middle (c) on the right -
13.⚖️ What colour is the text of this element?
<h2 class="note" id="logo">Hi</h2>
CSS:
#logo { color: red; }
.note { color: purple; }
h2 { color: white; } (a) orange (b) white (c) purple (d) red - 14.🎯 What kind of selector is #top? (a) an id selector (b) an element selector (c) a class selector
- 15.📱 Responsive design means a page ___. (a) fits every screen (b) is only for laptops (c) never changes (d) has no pictures
- 16.🌈 In #000095 the blue part is the hex number 95. What is it as a normal number?
-
17.⚖️ What colour is the text of this element?
<h1 class="red" id="top">Hi</h1>
CSS:
h1 { color: white; }
.red { color: purple; }
#top { color: black; } (a) purple (b) yellow (c) white (d) black -
18.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 80px;
padding: 10px;
border: 3px solid black;
margin: 10px;
} -
19.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 250px;
padding: 30px;
border: 5px solid black;
margin: 15px;
} - 20.True or false: HTML changes the text size. (a) True (b) False
-
21.🖌️ What colour are the letters?
h2 {
background-color: orange;
font-size: 28px;
text-align: right;
color: white;
} (a) red (b) white (c) orange - 22.🌈 Which colour is #ff0000? (a) white (b) bright green (c) blue (d) red
-
23.✍️ Which property is set to yellow in this rule?
p {
width: 300px;
background-color: yellow;
border: 2px solid;
} (a) yellow (b) padding (c) margin (d) background-color - 24.💪 Which flexbox property sets space between boxes? (a) display: flex (b) gap (c) flex-direction (d) align-items
-
25.🎯 Which CSS selector matches this element?
<div class="menu" id="end">Hello</div> (a) .note (b) span (c) div (d) .end - 26.🌈 Which colour of light is strongest in rgb(62, 180, 101)? (a) blue (b) green (c) red
- 27.🌈 Which colour is #ff00ff? (a) bright green (b) yellow (c) magenta (d) cyan
- 28.🌈 Which colour of light is strongest in rgb(194, 100, 85)? (a) blue (b) green (c) red
-
29.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 160px;
padding: 20px;
border: 4px solid black;
margin: 15px;
} - 30.🌈 Hex digits go 0 to 9, then A to which letter? (a) G (b) Z (c) J (d) F
-
31.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 14px;
}
} - 32.🌈 Which hex code is magenta? (a) #ff0000 (b) #ffff00 (c) #ff00ff (d) #00ff00
- 33.True or false: .menu is a class selector. (a) True (b) False
-
34.🖌️ What colour is behind the letters?
h1 {
background-color: orange;
font-size: 24px;
color: green;
text-align: left;
} (a) orange (b) yellow (c) green -
35.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 70px;
padding: 20px;
border: 4px solid black;
margin: 15px;
} -
36.✍️ How many declarations (property: value pairs) are in this rule?
p {
background-color: yellow;
text-align: center;
} - 37.📦 In the box model, which part is the line round the box? (a) padding (b) border (c) margin (d) content
- 38.✍️ How does a CSS comment start? (a) # (b) /* (c) <!-- (d) //
- 39.🎯 How many elements on a page should have the same id? (a) 2 (b) any number (c) 5 (d) 1
- 40.🎯 Which element does the selector h1 style? (a) <h2> (b) <h1 class="red"> (c) <div id="hero"> (d) <li class="red">
Answer key
- No
- background-color
- the later one
- 2
- justify-content
- 50
- 2
- False
- changes the page live
- border
- 80
- on the right
- red
- an id selector
- fits every screen
- 149
- black
- 126
- 350
- False
- white
- red
- background-color
- gap
- div
- green
- magenta
- red
- 238
- F
- 20
- #ff00ff
- True
- orange
- 148
- 2
- border
- /*
- 1
- <h1 class="red">
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids