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.✍️ What value is given to background-color in this rule?
li {
font-weight: bold;
background-color: yellow;
} (a) background-color (b) 8px (c) yellow (d) 10px - 2.True or false: #top is an id selector. (a) False (b) True
-
3.🖌️ How big is the text, in px?
h1 {
font-size: 20px;
color: white;
background-color: purple;
text-align: center;
} - 4.Which of these does HTML do? (a) reacts to a button click (b) gives the page structure (c) lays out the page (d) changes the text size
- 5.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the viewport meta tag (c) the title tag (d) the br tag
-
6.🎯 Which CSS selector matches this element?
<h2 class="big" id="end">Hello</h2> (a) #big (b) .red (c) h2 (d) .end -
7.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 130px;
justify-content: flex-end;
}
Inside are 2 boxes, each 40px wide (no margins). - 8.💪 Which justify-content value packs boxes at the end? (a) center (b) flex-start (c) flex-end (d) space-between
- 9.Which of these does HTML do? (a) makes headings and lists (b) checks a quiz answer (c) adds space around boxes (d) shows a pop-up message
-
10.✍️ How many declarations (property: value pairs) are in this rule?
.box {
font-size: 20px;
border: 2px solid;
margin: 10px;
text-align: center;
} -
11.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 10px;
}
} (a) No (b) Yes - 12.True or false: .menu is a class selector. (a) True (b) False
-
13.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 16px;
}
} - 14.✍️ In color: blue; which part is the property? (a) ; (b) blue (c) : (d) color
- 15.What does background-color do? (a) picks the font style (b) makes letters bigger (c) colours behind the text (d) makes the text bold
- 16.🎯 Which element does the selector #main style? (a) <p id="logo"> (b) <p id="main"> (c) <h1 class="box"> (d) <p class="main">
-
17.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 14px;
}
} (a) No (b) Yes - 18.💪 Which flexbox property sets space between boxes? (a) flex-direction (b) justify-content (c) display: flex (d) gap
-
19.✍️ How many declarations (property: value pairs) are in this rule?
body {
margin: 10px;
text-align: center;
} - 20.True or false: CSS makes a link. (a) False (b) True
-
21.✍️ Which property is set to italic in this rule?
.box {
background-color: yellow;
width: 300px;
font-style: italic;
} (a) font-style (b) font-size (c) color (d) italic - 22.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) red (c) blue (d) white
-
23.✍️ What is the selector in this CSS rule?
.box {
font-size: 20px;
border: 2px solid;
padding: 8px;
} (a) font-size (b) 2px solid (c) h2 (d) .box -
24.🖌️ What colour are the letters?
h1 {
text-align: left;
color: black;
font-size: 12px;
background-color: orange;
} (a) orange (b) black (c) green - 25.🖌️ Which CSS property picks the font style? (a) font-family (b) text-align (c) font-size (d) background-color
- 26.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the first one (c) neither (d) the later one
-
27.✍️ Which property is set to 2px solid in this rule?
body {
border: 2px solid;
margin: 10px;
} (a) font-style (b) width (c) border (d) 2px solid -
28.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} -
29.✍️ Which property is set to red in this rule?
.note {
padding: 8px;
color: red;
width: 300px;
} (a) red (b) font-size (c) text-align (d) color -
30.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 100px;
padding: 25px;
border: 4px solid black;
margin: 0px;
} - 31.True or false: #top is a class selector. (a) True (b) False
- 32.🎯 What kind of selector is img? (a) an id selector (b) a class selector (c) an element selector
- 33.Which of these does JavaScript do? (a) rounds box corners (b) makes headings and lists (c) reacts to a button click (d) lays out the page
-
34.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 200px;
padding: 10px;
border: 2px solid black;
margin: 10px;
} - 35.True or false: CSS changes the page live. (a) False (b) True
- 36.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
-
37.⚖️ What colour is the text of this element?
<p class="star" id="main">Hi</p>
CSS:
p { color: green; }
p { color: white; } (a) orange (b) purple (c) green (d) white - 38.💪 Which justify-content value packs boxes at the start? (a) space-between (b) flex-start (c) flex-end (d) center
- 39.💪 Which justify-content value puts boxes in the middle? (a) flex-end (b) space-between (c) center (d) flex-start
-
40.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 1024px) {
p {
font-size: 18px;
}
} (a) Yes (b) No
Answer key
- yellow
- True
- 20
- gives the page structure
- the viewport meta tag
- h2
- 50
- flex-end
- makes headings and lists
- 4
- No
- True
- 20
- color
- colours behind the text
- <p id="main">
- No
- gap
- 2
- False
- font-style
- blue
- .box
- black
- font-family
- the later one
- border
- 24
- color
- 158
- False
- an element selector
- reacts to a button click
- 224
- False
- an element selector
- white
- flex-start
- center
- No
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids