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.🎯 Which element does the selector p style? (a) <h2 class="red"> (b) <p class="red"> (c) <li id="top"> (d) <h1>
-
2.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 6px;
}
} - 3.Which of these is the border? (a) space outside the border (b) space inside the border (c) the gap to other boxes (d) the line round the box
-
4.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 20px;
}
} (a) No (b) Yes - 5.🎯 Can many elements share the same class? (a) No (b) Yes
- 6.🎯 Which sign starts an id selector? (a) @ (b) . (c) # (d) &
- 7.🎯 Which element does the selector li style? (a) <span class="star"> (b) <div> (c) <li class="star"> (d) <p id="main">
- 8.What does justify-content: flex-end do? (a) packs boxes at the start (b) equal gaps, none at ends (c) packs boxes at the end (d) puts boxes in the middle
- 9.✍️ CSS declarations go inside which brackets? (a) ( ) (b) [ ] (c) { } (d) < >
-
10.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 110px;
padding: 15px;
border: 4px solid black;
margin: 0px;
} - 11.🎯 Which element does the selector div style? (a) <div class="red"> (b) <h1 id="intro"> (c) <p class="red"> (d) <span>
-
12.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 210px;
justify-content: flex-start;
}
Inside are 4 boxes, each 40px wide (no margins). - 13.What does font-size do? (a) makes the text bold (b) sets the letter colour (c) makes letters bigger (d) centres a heading
- 14.✍️ In color: blue; which part is the value? (a) : (b) ; (c) color (d) blue
- 15.🌈 Which colour of light is strongest in rgb(1, 154, 10)? (a) blue (b) red (c) green
- 16.✍️ Which sign ends each CSS declaration? (a) . (b) ; (c) , (d) :
- 17.💪 Which justify-content value packs boxes at the start? (a) center (b) flex-end (c) flex-start (d) space-between
-
18.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 80px;
padding: 5px;
border: 2px solid black;
margin: 0px;
} - 19.📱 What does a media query check? (a) the battery level (b) the screen width (c) the time of day (d) the page title
-
20.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 110px;
padding: 5px;
border: 5px solid black;
margin: 5px;
} -
21.✍️ What is the selector in this CSS rule?
p {
font-weight: bold;
font-style: italic;
padding: 8px;
} (a) p (b) italic (c) .note (d) font-weight - 22.🧩 Which language shows a pop-up message? (a) HTML (b) JavaScript (c) CSS
-
23.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} -
24.⚖️ What colour is the text of this element?
<p class="star" id="intro">Hi</p>
CSS:
.star { color: purple; }
p { color: blue; }
#intro { color: red; } (a) purple (b) blue (c) red (d) yellow - 25.🧩 Which language counts down a timer? (a) JavaScript (b) CSS (c) HTML
- 26.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 6 (b) 2 (c) 4 (d) 3
-
27.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 140px;
justify-content: center;
}
Inside are 3 boxes, each 40px wide (no margins). - 28.True or false: #hero is an id selector. (a) True (b) False
- 29.What does color do? (a) colours behind the text (b) sets the letter colour (c) centres a heading (d) makes letters bigger
-
30.⚖️ What colour is the text of this element?
<p class="note" id="top">Hi</p>
CSS:
.note { color: purple; }
#top { color: orange; } (a) orange (b) purple (c) blue (d) red - 31.True or false: body is an element selector. (a) False (b) True
- 32.True or false: padding is the gap round content. (a) True (b) False
-
33.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
background-color: yellow;
font-size: 20px;
font-style: italic;
} - 34.📦 In the box model, which part is the line round the box? (a) margin (b) padding (c) border (d) content
-
35.🖌️ What colour are the letters?
li {
color: blue;
background-color: white;
text-align: left;
font-size: 12px;
} (a) green (b) blue (c) white - 36.💪 Which flexbox property sets space between boxes? (a) display: flex (b) flex-direction (c) gap (d) justify-content
- 37.🎯 Which element does the selector .big style? (a) <h2 class="big"> (b) <h2 class="red"> (c) <li class="box"> (d) <h2 id="big">
- 38.True or false: .star is an id selector. (a) True (b) False
- 39.💪 Which flexbox property picks row or column? (a) gap (b) flex-direction (c) display: flex (d) justify-content
-
40.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 768px) {
p {
font-size: 26px;
}
}
Answer key
- <p class="red">
- 6
- the line round the box
- No
- Yes
- #
- <li class="star">
- packs boxes at the end
- { }
- 148
- <div class="red">
- 50
- makes letters bigger
- blue
- green
- ;
- flex-start
- 94
- the screen width
- 140
- p
- JavaScript
- 16
- red
- JavaScript
- 3
- 10
- True
- sets the letter colour
- orange
- True
- True
- 3
- border
- blue
- gap
- <h2 class="big">
- False
- flex-direction
- 24
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids