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 is the selector in this CSS rule?
h2 {
border: 2px solid;
padding: 8px;
} (a) border (b) h2 (c) h1 (d) 8px - 2.📱 Responsive design means a page ___. (a) fits every screen (b) never changes (c) has no pictures (d) is only for laptops
-
3.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 600px) {
p {
font-size: 24px;
}
} -
4.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 16px;
}
} - 5.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
-
6.🎯 Which CSS selector matches this element?
<p class="box" id="hero">Hello</p> (a) #top (b) #hero (c) #box (d) .star - 7.🌈 Which hex code is black? (a) #00ffff (b) #0000ff (c) #ffffff (d) #000000
- 8.✍️ Which sign goes between a property and its value? (a) = (b) : (c) - (d) ;
- 9.🎯 Which element does the selector .box style? (a) <h1 class="star"> (b) <h2 class="menu"> (c) <h1 class="box"> (d) <h1 id="box">
-
10.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 340px;
justify-content: center;
}
Inside are 3 boxes, each 60px wide (no margins). - 11.🌈 Which colour is #000000? (a) bright green (b) magenta (c) black (d) red
- 12.🎯 How many elements on a page should have the same id? (a) any number (b) 5 (c) 1 (d) 2
- 13.🖌️ Which CSS property colours behind the text? (a) color (b) background-color (c) font-weight (d) font-size
- 14.🧩 Which language puts a picture on a page? (a) CSS (b) JavaScript (c) HTML
-
15.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 320px;
justify-content: flex-end;
}
Inside are 3 boxes, each 80px wide (no margins). - 16.🎨 One CSS file can style how many pages? (a) many pages (b) only one image (c) only one word (d) no pages
- 17.🧩 Which language makes headings and lists? (a) JavaScript (b) CSS (c) HTML
- 18.🖌️ Which CSS property makes the text bold? (a) font-size (b) background-color (c) font-family (d) font-weight
- 19.What does justify-content: flex-end do? (a) packs boxes at the end (b) puts boxes in the middle (c) packs boxes at the start (d) equal gaps, none at ends
- 20.True or false: body is a class selector. (a) True (b) False
-
21.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 220px;
padding: 10px;
border: 5px solid black;
margin: 15px;
} - 22.Which of these does HTML do? (a) counts down a timer (b) adds space around boxes (c) makes a form box (d) shows a pop-up message
-
23.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 270px;
justify-content: flex-start;
}
Inside are 4 boxes, each 50px wide (no margins). - 24.True or false: CSS checks a quiz answer. (a) True (b) False
-
25.⚖️ What colour is the text of this element?
<h2 class="star" id="main">Hi</h2>
CSS:
.star { color: red; }
.star { color: green; } (a) orange (b) green (c) blue (d) red - 26.True or false: margin is the gap to other boxes. (a) False (b) True
- 27.💪 Which justify-content value packs boxes at the end? (a) flex-end (b) center (c) space-between (d) flex-start
- 28.What does justify-content: flex-start do? (a) packs boxes at the start (b) puts boxes in the middle (c) packs boxes at the end (d) equal gaps, none at ends
- 29.🖌️ Which CSS property picks the font style? (a) background-color (b) color (c) font-family (d) text-align
- 30.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) neither (c) the shorter one (d) the later one
- 31.True or false: margin is the gap round content. (a) False (b) True
-
32.⚖️ What colour is the text of this element?
<h1 class="note" id="hero">Hi</h1>
CSS:
#hero { color: red; }
#hero { color: green; } (a) black (b) blue (c) red (d) green - 33.True or false: JavaScript sets colours and fonts. (a) True (b) False
- 34.🔍 Which is the odd one out? (a) changes the page live (b) shows a pop-up message (c) reacts to a button click (d) puts a picture on a page
- 35.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) 800px or wider (c) exactly 100px (d) turned off
- 36.Which of these does CSS do? (a) makes headings and lists (b) puts a picture on a page (c) adds space around boxes (d) counts down a timer
- 37.🌈 Hex digits go 0 to 9, then A to which letter? (a) J (b) G (c) Z (d) F
- 38.🌈 Which colour is #ff00ff? (a) white (b) red (c) bright green (d) magenta
-
39.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 220px;
justify-content: space-between;
}
Inside are 4 boxes, each 40px wide (no margins). - 40.🧩 Which language checks a quiz answer? (a) CSS (b) JavaScript (c) HTML
Answer key
- h2
- fits every screen
- 24
- 20
- an id selector
- #hero
- #000000
- :
- <h1 class="box">
- 80
- black
- 1
- background-color
- HTML
- 80
- many pages
- HTML
- font-weight
- packs boxes at the end
- False
- 250
- makes a form box
- 70
- False
- green
- True
- flex-end
- packs boxes at the start
- font-family
- the later one
- False
- green
- False
- puts a picture on a page
- 800px or wider
- adds space around boxes
- F
- magenta
- 20
- JavaScript
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids