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.📱 Responsive design means a page ___. (a) is only for laptops (b) never changes (c) has no pictures (d) fits every screen
-
2.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 80px;
padding: 15px;
border: 1px solid black;
margin: 10px;
} -
3.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 160px;
justify-content: center;
}
Inside are 2 boxes, each 50px wide (no margins). - 4.🎯 Which element does the selector .note style? (a) <h2 class="note"> (b) <li class="red"> (c) <h2 id="note"> (d) <h2 class="big">
-
5.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 440px;
justify-content: center;
}
Inside are 4 boxes, each 100px wide (no margins). -
6.⚖️ What colour is the text of this element?
<h2 class="box" id="intro">Hi</h2>
CSS:
.box { color: black; }
.box { color: yellow; } (a) white (b) yellow (c) black (d) blue -
7.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 1024px) {
p {
font-size: 22px;
}
} - 8.True or false: .big is a class selector. (a) True (b) False
- 9.🖌️ Which CSS property colours behind the text? (a) font-family (b) background-color (c) font-size (d) font-weight
- 10.🧩 Which language checks a quiz answer? (a) JavaScript (b) HTML (c) CSS
- 11.What does justify-content: flex-end 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
-
12.🖌️ What colour are the letters?
p {
font-size: 16px;
text-align: center;
color: blue;
background-color: black;
} (a) black (b) blue (c) yellow -
13.⚖️ What colour is the text of this element?
<p class="star" id="hero">Hi</p>
CSS:
.star { color: orange; }
.star { color: white; } (a) green (b) purple (c) orange (d) white -
14.✍️ What value is given to background-color in this rule?
h2 {
margin: 10px;
background-color: yellow;
font-style: italic;
border: 2px solid;
} (a) 10px (b) 8px (c) yellow (d) background-color - 15.🎯 What kind of selector is .note? (a) a class selector (b) an id selector (c) an element selector
- 16.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) neither (c) the later one (d) the shorter one
-
17.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 24px;
}
} (a) Yes (b) No -
18.⚖️ What colour is the text of this element?
<p class="red" id="top">Hi</p>
CSS:
p { color: black; }
p { color: orange; } (a) white (b) green (c) orange (d) black -
19.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} - 20.🌈 In #000097 the blue part is the hex number 97. What is it as a normal number?
- 21.True or false: .star is an element selector. (a) False (b) True
- 22.🎯 Which sign starts a class selector? (a) @ (b) # (c) . (d) &
- 23.💪 Which justify-content value puts boxes in the middle? (a) flex-end (b) center (c) flex-start (d) space-between
-
24.✍️ Which property is set to 20px in this rule?
li {
font-style: italic;
font-size: 20px;
color: red;
} (a) background-color (b) 20px (c) text-align (d) font-size - 25.True or false: CSS sets colours and fonts. (a) True (b) False
- 26.🎨 Which attribute adds CSS inside one tag? (a) alt (b) href (c) style (d) src
-
27.⚖️ What colour is the text of this element?
<h1 class="box" id="main">Hi</h1>
CSS:
.box { color: blue; }
#main { color: white; }
h1 { color: yellow; } (a) white (b) yellow (c) blue (d) orange - 28.True or false: padding is space inside the border. (a) True (b) False
- 29.🖌️ Which CSS property picks the font style? (a) color (b) background-color (c) font-size (d) font-family
-
30.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 230px;
justify-content: space-between;
}
Inside are 2 boxes, each 100px wide (no margins). -
31.⚖️ What colour is the text of this element?
<h2 class="big" id="main">Hi</h2>
CSS:
h2 { color: yellow; }
h2 { color: purple; } (a) yellow (b) green (c) red (d) purple - 32.Which of these does JavaScript do? (a) puts a picture on a page (b) makes a link (c) reacts to a button click (d) rounds box corners
- 33.Which of these does CSS do? (a) gives the page structure (b) shows a pop-up message (c) makes a link (d) changes the text size
-
34.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 160px;
padding: 25px;
border: 3px solid black;
margin: 15px;
} - 35.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 6 (b) 3 (c) 4 (d) 2
- 36.🌈 Which colour is #ff00ff? (a) yellow (b) bright green (c) magenta (d) blue
-
37.🖌️ What colour are the letters?
li {
background-color: white;
font-size: 40px;
text-align: center;
color: purple;
} (a) white (b) purple (c) red -
38.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 320px;
justify-content: flex-end;
}
Inside are 3 boxes, each 80px wide (no margins). - 39.💪 Which flexbox property spaces boxes along a row? (a) gap (b) align-items (c) justify-content (d) flex-direction
-
40.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 30px;
}
}
Answer key
- fits every screen
- 132
- 30
- <h2 class="note">
- 20
- yellow
- 24
- True
- background-color
- JavaScript
- packs boxes at the end
- blue
- white
- yellow
- a class selector
- the later one
- No
- orange
- 18
- 151
- False
- .
- center
- font-size
- True
- style
- white
- True
- font-family
- 30
- purple
- reacts to a button click
- changes the text size
- 246
- 3
- magenta
- purple
- 80
- justify-content
- 24
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids