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.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 160px;
justify-content: flex-start;
}
Inside are 3 boxes, each 40px wide (no margins). - 2.True or false: the border is space inside the border. (a) False (b) True
-
3.✍️ What is the selector in this CSS rule?
p {
background-color: yellow;
width: 300px;
margin: 10px;
font-style: italic;
} (a) p (b) 300px (c) background-color (d) .note -
4.✍️ How many declarations (property: value pairs) are in this rule?
#top {
color: red;
margin: 10px;
font-weight: bold;
} - 5.🎯 Can many elements share the same class? (a) Yes (b) No
- 6.Which of these is padding? (a) the line round the box (b) a solid or dotted edge (c) the gap to other boxes (d) the gap round content
-
7.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 230px;
padding: 10px;
border: 4px solid black;
margin: 15px;
} -
8.🎯 Which CSS selector matches this element?
<div class="note" id="hero">Hello</div> (a) #note (b) #top (c) span (d) #hero - 9.🧩 Which language gives the page structure? (a) CSS (b) JavaScript (c) HTML
-
10.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 8px;
}
} -
11.✍️ What is the selector in this CSS rule?
.box {
padding: 8px;
color: red;
} (a) h2 (b) .box (c) red (d) padding - 12.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the first one (c) the shorter one (d) neither
-
13.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 768px) {
p {
font-size: 12px;
}
} (a) Yes (b) No - 14.💪 Which justify-content value puts boxes in the middle? (a) center (b) flex-end (c) flex-start (d) space-between
- 15.True or false: padding is space inside the border. (a) True (b) False
- 16.🌈 Which colour of light is strongest in rgb(177, 4, 123)? (a) blue (b) green (c) red
- 17.🌈 Hex digits go 0 to 9, then A to which letter? (a) Z (b) J (c) G (d) F
-
18.✍️ What is the selector in this CSS rule?
h1 {
background-color: yellow;
margin: 10px;
} (a) background-color (b) h1 (c) p (d) 10px -
19.⚖️ What colour is the text of this element?
<p class="box" id="end">Hi</p>
CSS:
p { color: purple; }
p { color: red; } (a) orange (b) purple (c) green (d) red - 20.🧩 Which language makes a link? (a) CSS (b) JavaScript (c) HTML
-
21.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
text-align: center;
color: red;
font-size: 20px;
font-weight: bold;
} - 22.🎯 Which sign starts a class selector? (a) # (b) . (c) @ (d) &
- 23.🌈 Which colour of light is strongest in rgb(83, 136, 182)? (a) blue (b) red (c) green
-
24.⚖️ What colour is the text of this element?
<h1 class="big" id="intro">Hi</h1>
CSS:
.big { color: purple; }
h1 { color: yellow; } (a) black (b) yellow (c) blue (d) purple -
25.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 310px;
justify-content: flex-end;
}
Inside are 4 boxes, each 60px wide (no margins). - 26.What does background-color do? (a) makes the text bold (b) colours behind the text (c) makes letters bigger (d) centres a heading
- 27.🎯 Which sign starts an id selector? (a) @ (b) & (c) . (d) #
- 28.🧩 Which language adds space around boxes? (a) HTML (b) JavaScript (c) CSS
-
29.🖌️ How big is the text, in px?
h2 {
text-align: center;
background-color: red;
font-size: 12px;
color: white;
} - 30.🎯 What kind of selector is h1? (a) an id selector (b) an element selector (c) a class selector
- 31.✍️ In color: blue; which part is the property? (a) ; (b) blue (c) : (d) color
-
32.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 70px;
padding: 15px;
border: 1px solid black;
margin: 10px;
} - 33.True or false: p is a class selector. (a) True (b) False
- 34.🎨 Which attribute adds CSS inside one tag? (a) alt (b) style (c) href (d) src
- 35.✍️ Which sign goes between a property and its value? (a) ; (b) - (c) = (d) :
-
36.✍️ What value is given to background-color in this rule?
body {
background-color: yellow;
font-style: italic;
} (a) 8px (b) 10px (c) background-color (d) yellow -
37.✍️ How many declarations (property: value pairs) are in this rule?
p {
border: 2px solid;
font-size: 20px;
padding: 8px;
font-weight: bold;
} - 38.What does font-size do? (a) centres a heading (b) makes letters bigger (c) sets the letter colour (d) makes the text bold
-
39.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 190px;
padding: 10px;
border: 4px solid black;
margin: 0px;
} -
40.🖌️ Where does the text sit on its line?
li {
text-align: right;
background-color: purple;
font-size: 28px;
color: black;
} (a) on the left (b) in the middle (c) on the right
Answer key
- 40
- False
- p
- 3
- Yes
- the gap round content
- 288
- #hero
- HTML
- 8
- .box
- the later one
- Yes
- center
- True
- red
- F
- h1
- red
- HTML
- 4
- .
- blue
- purple
- 70
- colours behind the text
- #
- CSS
- 12
- an element selector
- color
- 102
- False
- style
- :
- yellow
- 4
- makes letters bigger
- 218
- on the right
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids