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?
h2 {
padding: 8px;
text-align: center;
background-color: yellow;
width: 300px;
} (a) background-color (b) 8px (c) yellow (d) 10px - 2.🌈 Which colour is #ffffff? (a) bright green (b) white (c) yellow (d) magenta
- 3.🔍 Which is the odd one out? (a) makes headings and lists (b) counts down a timer (c) reacts to a button click (d) changes the page live
-
4.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 28px;
}
} -
5.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 60px;
padding: 15px;
border: 4px solid black;
margin: 0px;
} - 6.🌈 Which colour is #000000? (a) magenta (b) cyan (c) black (d) blue
- 7.🧩 Which language reacts to a button click? (a) CSS (b) JavaScript (c) HTML
- 8.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the br tag (c) the viewport meta tag (d) the hr tag
- 9.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
- 10.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) neither (c) the later one (d) the first one
- 11.🌈 What is the biggest number one colour can have in rgb()? (a) 255 (b) 99 (c) 1000 (d) 100
- 12.💪 Which flexbox property lines boxes up across? (a) display: flex (b) gap (c) align-items (d) flex-direction
- 13.🔍 Which is the odd one out? (a) changes the page live (b) sets colours and fonts (c) changes the text size (d) rounds box corners
-
14.✍️ Which property is set to 8px in this rule?
#top {
margin: 10px;
padding: 8px;
font-weight: bold;
} (a) 8px (b) font-weight (c) border (d) padding -
15.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 14px;
}
} (a) Yes (b) No - 16.True or false: the content is a solid or dotted edge. (a) True (b) False
-
17.✍️ Which property is set to italic in this rule?
#top {
font-style: italic;
font-weight: bold;
padding: 8px;
margin: 10px;
} (a) italic (b) font-style (c) color (d) font-size - 18.💪 Which justify-content value packs boxes at the start? (a) center (b) flex-start (c) space-between (d) flex-end
-
19.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 20px;
}
} - 20.True or false: padding is space inside the border. (a) True (b) False
- 21.✍️ How does a CSS comment start? (a) // (b) # (c) <!-- (d) /*
- 22.True or false: p is an element selector. (a) True (b) False
-
23.🎯 Which CSS selector matches this element?
<span class="big" id="hero">Hello</span> (a) span (b) .red (c) #big (d) #top - 24.🧩 Which language shows a pop-up message? (a) HTML (b) CSS (c) JavaScript
- 25.What does font-size do? (a) colours behind the text (b) makes letters bigger (c) picks the font style (d) sets the letter colour
- 26.What does justify-content: flex-start do? (a) puts boxes in the middle (b) packs boxes at the start (c) packs boxes at the end (d) equal gaps, none at ends
-
27.⚖️ What colour is the text of this element?
<h1 class="star" id="top">Hi</h1>
CSS:
h1 { color: blue; }
h1 { color: purple; } (a) red (b) blue (c) black (d) purple - 28.Which of these does CSS do? (a) makes headings and lists (b) changes the text size (c) shows a pop-up message (d) makes a form box
- 29.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) 800px or wider (c) exactly 100px (d) 800px or narrower
- 30.True or false: padding is the gap to other boxes. (a) True (b) False
- 31.🎯 Which element does the selector h1 style? (a) <li class="red"> (b) <h1 class="red"> (c) <h2> (d) <div id="logo">
-
32.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
border: 2px solid;
} - 33.🌈 Which colour is #ff00ff? (a) red (b) cyan (c) magenta (d) yellow
- 34.✍️ Which sign goes between a property and its value? (a) : (b) ; (c) - (d) =
- 35.🧩 Which language makes a form box? (a) JavaScript (b) HTML (c) CSS
-
36.✍️ What is the selector in this CSS rule?
p {
text-align: center;
background-color: yellow;
} (a) yellow (b) p (c) text-align (d) .note - 37.🧩 Which language makes a link? (a) CSS (b) JavaScript (c) HTML
-
38.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 600px) {
p {
font-size: 26px;
}
} -
39.✍️ How many declarations (property: value pairs) are in this rule?
.note {
text-align: center;
} -
40.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 270px;
padding: 20px;
border: 2px solid black;
margin: 0px;
}
Answer key
- yellow
- white
- makes headings and lists
- 20
- 98
- black
- JavaScript
- the viewport meta tag
- an element selector
- the later one
- 255
- align-items
- changes the page live
- padding
- No
- False
- font-style
- flex-start
- 24
- True
- /*
- True
- span
- JavaScript
- makes letters bigger
- packs boxes at the start
- purple
- changes the text size
- 800px or wider
- False
- <h1 class="red">
- 1
- magenta
- :
- HTML
- p
- HTML
- 26
- 1
- 314
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids