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 does text-align do? (a) picks the font style (b) centres a heading (c) sets the letter colour (d) colours behind the text
- 2.📱 Responsive design means a page ___. (a) fits every screen (b) never changes (c) has no pictures (d) is only for laptops
- 3.True or false: the border is the line round the box. (a) True (b) False
-
4.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
width: 300px;
font-size: 20px;
border: 2px solid;
} -
5.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 1024px) {
p {
font-size: 24px;
}
} - 6.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the later one (c) the first one (d) the shorter one
-
7.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 6px;
}
} - 8.🎯 What kind of selector is h1? (a) an element selector (b) a class selector (c) an id selector
-
9.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 70px;
padding: 25px;
border: 2px solid black;
margin: 10px;
} -
10.⚖️ What colour is the text of this element?
<h2 class="box" id="main">Hi</h2>
CSS:
h2 { color: orange; }
h2 { color: red; } (a) purple (b) red (c) yellow (d) orange - 11.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
-
12.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 20px;
}
} -
13.✍️ What value is given to background-color in this rule?
p {
text-align: center;
color: red;
font-size: 20px;
background-color: yellow;
} (a) 8px (b) yellow (c) background-color (d) 10px - 14.🖌️ Which CSS property makes the text bold? (a) font-weight (b) color (c) background-color (d) text-align
-
15.🖌️ How big is the text, in px?
li {
background-color: orange;
color: green;
font-size: 24px;
text-align: right;
} -
16.🖌️ What colour are the letters?
li {
color: yellow;
text-align: center;
font-size: 20px;
background-color: blue;
} (a) yellow (b) black (c) blue -
17.✍️ What is the selector in this CSS rule?
.box {
width: 300px;
border: 2px solid;
padding: 8px;
} (a) h2 (b) .box (c) width (d) 2px solid - 18.🧩 Which language adds space around boxes? (a) CSS (b) HTML (c) JavaScript
- 19.💪 Which flexbox property sets space between boxes? (a) gap (b) display: flex (c) align-items (d) flex-direction
-
20.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 30px;
}
} -
21.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} -
22.🖌️ Where does the text sit on its line?
li {
color: red;
text-align: center;
font-size: 12px;
background-color: green;
} (a) on the right (b) in the middle (c) on the left -
23.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 22px;
}
} - 24.🧩 Which language lays out the page? (a) CSS (b) HTML (c) JavaScript
- 25.🌈 Which colour is #ff0000? (a) magenta (b) blue (c) red (d) white
-
26.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 18px;
}
} (a) Yes (b) No -
27.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 150px;
justify-content: flex-start;
}
Inside are 2 boxes, each 60px wide (no margins). - 28.🖌️ Which CSS property sets the letter colour? (a) background-color (b) color (c) font-family (d) font-weight
- 29.💪 Which flexbox property lines boxes up across? (a) flex-direction (b) display: flex (c) justify-content (d) align-items
- 30.📱 Which tag helps phones show a page at the right size? (a) the br tag (b) the viewport meta tag (c) the hr tag (d) the title tag
- 31.🌈 In #050000 the red part is the hex number 05. What is it as a normal number?
- 32.💪 Which justify-content value puts boxes in the middle? (a) space-between (b) center (c) flex-end (d) flex-start
- 33.What does font-size do? (a) sets the letter colour (b) makes letters bigger (c) picks the font style (d) colours behind the text
- 34.True or false: the content is the line round the box. (a) True (b) False
-
35.🖌️ Where does the text sit on its line?
li {
text-align: left;
color: black;
background-color: purple;
font-size: 24px;
} (a) on the left (b) on the right (c) in the middle - 36.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) red (c) blue (d) white
- 37.🖌️ Which CSS property centres a heading? (a) background-color (b) font-size (c) text-align (d) font-family
- 38.True or false: img is an element selector. (a) False (b) True
-
39.✍️ How many declarations (property: value pairs) are in this rule?
p {
width: 300px;
font-style: italic;
} - 40.Which of these is the border? (a) a solid or dotted edge (b) space outside the border (c) the text or picture (d) the gap to other boxes
Answer key
- centres a heading
- fits every screen
- True
- 3
- 20
- the later one
- 6
- an element selector
- 144
- red
- an element selector
- 20
- yellow
- font-weight
- 24
- yellow
- .box
- CSS
- gap
- 24
- 20
- in the middle
- 24
- CSS
- red
- No
- 30
- color
- align-items
- the viewport meta tag
- 5
- center
- makes letters bigger
- False
- on the left
- blue
- text-align
- True
- 2
- a solid or dotted edge
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids