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.✍️ In color: blue; which part is the value? (a) blue (b) color (c) ; (d) :
-
2.✍️ Which property is set to 20px in this rule?
body {
font-size: 20px;
border: 2px solid;
text-align: center;
width: 300px;
} (a) font-size (b) text-align (c) background-color (d) 20px - 3.📦 In the box model, which part is space outside the border? (a) padding (b) margin (c) border (d) content
- 4.🌈 Which colour is #ff00ff? (a) red (b) magenta (c) cyan (d) yellow
- 5.🔍 Which is the odd one out? (a) sets colours and fonts (b) adds space around boxes (c) makes headings and lists (d) rounds box corners
-
6.✍️ How many declarations (property: value pairs) are in this rule?
li {
margin: 10px;
font-size: 20px;
color: red;
} -
7.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} - 8.🎨 Which tag connects an outside CSS file? (a) <a> (b) <link> (c) <img> (d) <css>
- 9.True or false: .note is a class selector. (a) True (b) False
-
10.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 140px;
padding: 15px;
border: 3px solid black;
margin: 20px;
} -
11.🖌️ How big is the text, in px?
h2 {
font-size: 36px;
text-align: right;
background-color: blue;
color: red;
} - 12.True or false: JavaScript makes headings and lists. (a) True (b) False
- 13.🧩 Which language adds space around boxes? (a) JavaScript (b) CSS (c) HTML
-
14.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 1024px) {
p {
font-size: 20px;
}
} -
15.⚖️ What colour is the text of this element?
<h2 class="red" id="main">Hi</h2>
CSS:
h2 { color: black; }
h2 { color: red; } (a) red (b) black (c) white (d) purple - 16.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the later one (c) neither (d) the shorter one
- 17.True or false: padding is the gap round content. (a) True (b) False
-
18.🖌️ Where does the text sit on its line?
li {
text-align: right;
background-color: yellow;
font-size: 16px;
color: black;
} (a) on the right (b) on the left (c) in the middle -
19.✍️ What is the selector in this CSS rule?
h1 {
border: 2px solid;
margin: 10px;
} (a) border (b) 10px (c) h1 (d) p -
20.⚖️ What colour is the text of this element?
<h1 class="menu" id="end">Hi</h1>
CSS:
#end { color: black; }
#end { color: orange; } (a) orange (b) black (c) red (d) white - 21.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
- 22.💪 Which justify-content value packs boxes at the end? (a) space-between (b) flex-end (c) center (d) flex-start
- 23.🌈 What is the biggest number one colour can have in rgb()? (a) 255 (b) 99 (c) 100 (d) 1000
-
24.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 20px;
}
} - 25.✍️ In color: blue; which part is the property? (a) : (b) color (c) blue (d) ;
-
26.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 170px;
padding: 15px;
border: 2px solid black;
margin: 0px;
} - 27.📦 In the box model, which part is space inside the border? (a) padding (b) margin (c) content (d) border
-
28.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 280px;
padding: 30px;
border: 3px solid black;
margin: 5px;
} - 29.✍️ How does a CSS comment start? (a) /* (b) <!-- (c) // (d) #
- 30.True or false: the content is the gap to other boxes. (a) False (b) True
- 31.What does text-align do? (a) colours behind the text (b) makes the text bold (c) makes letters bigger (d) centres a heading
- 32.What does justify-content: flex-start do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the start (d) packs boxes at the end
-
33.⚖️ What colour is the text of this element?
<h1 class="box" id="intro">Hi</h1>
CSS:
#intro { color: yellow; }
.box { color: purple; } (a) blue (b) yellow (c) red (d) purple - 34.Which of these does JavaScript do? (a) gives the page structure (b) counts down a timer (c) adds space around boxes (d) makes a form box
-
35.🎯 Which CSS selector matches this element?
<h1 class="menu" id="logo">Hello</h1> (a) .menu (b) #menu (c) .note (d) h2 -
36.✍️ What is the selector in this CSS rule?
.note {
font-style: italic;
margin: 10px;
} (a) #top (b) .note (c) 10px (d) font-style -
37.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 210px;
justify-content: flex-start;
}
Inside are 3 boxes, each 50px wide (no margins). - 38.Which of these does JavaScript do? (a) changes the text size (b) reacts to a button click (c) rounds box corners (d) adds space around boxes
- 39.Which of these is the content? (a) the gap round content (b) the line round the box (c) space inside the border (d) the text or picture
- 40.💪 Which justify-content value packs boxes at the start? (a) center (b) space-between (c) flex-end (d) flex-start
Answer key
- blue
- font-size
- margin
- magenta
- makes headings and lists
- 3
- 10
- <link>
- True
- 216
- 36
- False
- CSS
- 24
- red
- the later one
- True
- on the right
- h1
- orange
- an element selector
- flex-end
- 255
- 12
- color
- 204
- padding
- 346
- /*
- False
- centres a heading
- packs boxes at the start
- yellow
- counts down a timer
- .menu
- .note
- 60
- reacts to a button click
- the text or picture
- flex-start
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids