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.True or false: CSS sets colours and fonts. (a) True (b) False
- 2.🌈 Which colour is rgb(255, 255, 255)? (a) blue (b) red (c) cyan (d) white
-
3.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 768px) {
p {
font-size: 14px;
}
} (a) Yes (b) No - 4.🔍 Which is the odd one out? (a) puts a picture on a page (b) makes a link (c) makes a form box (d) reacts to a button click
- 5.🧩 Which language changes the page live? (a) JavaScript (b) HTML (c) CSS
- 6.🎯 Can many elements share the same class? (a) No (b) Yes
- 7.True or false: p is an id selector. (a) False (b) True
-
8.🖌️ What colour is behind the letters?
p {
font-size: 20px;
color: purple;
text-align: center;
background-color: black;
} (a) purple (b) black (c) white - 9.💪 Which flexbox property turns on flexbox? (a) justify-content (b) gap (c) flex-direction (d) display: flex
- 10.What does justify-content: space-between do? (a) equal gaps, none at ends (b) packs boxes at the end (c) packs boxes at the start (d) puts boxes in the middle
- 11.💪 Which flexbox property lines boxes up across? (a) align-items (b) flex-direction (c) gap (d) display: flex
-
12.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 300px;
padding: 5px;
border: 2px solid black;
margin: 15px;
} - 13.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
- 14.🌈 Which colour is rgb(0, 255, 255)? (a) red (b) blue (c) bright green (d) cyan
- 15.🌈 Which colour is #000000? (a) blue (b) cyan (c) black (d) white
- 16.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) turned off (c) 800px or wider (d) exactly 100px
-
17.🖌️ How big is the text, in px?
li {
background-color: white;
font-size: 16px;
text-align: center;
color: green;
} - 18.🌈 In #130000 the red part is the hex number 13. What is it as a normal number?
-
19.✍️ What value is given to text-align in this rule?
.note {
font-size: 20px;
text-align: center;
} (a) 10px (b) center (c) text-align (d) yellow - 20.🖌️ Which CSS property centres a heading? (a) font-family (b) font-size (c) text-align (d) color
- 21.What does font-weight do? (a) sets the letter colour (b) centres a heading (c) makes letters bigger (d) makes the text bold
-
22.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 240px;
justify-content: flex-start;
}
Inside are 2 boxes, each 100px wide (no margins). - 23.📱 What does a media query check? (a) the page title (b) the screen width (c) the time of day (d) the battery level
- 24.🎯 Which element does the selector .big style? (a) <h2 class="red"> (b) <li class="box"> (c) <h2 id="big"> (d) <h2 class="big">
- 25.What does justify-content: flex-start 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
-
26.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 260px;
justify-content: flex-start;
}
Inside are 3 boxes, each 60px wide (no margins). - 27.🖌️ Which CSS property sets the letter colour? (a) font-family (b) font-size (c) background-color (d) color
-
28.🎯 Which CSS selector matches this element?
<h1 class="menu" id="end">Hello</h1> (a) #end (b) #menu (c) .note (d) #hero -
29.🖌️ Where does the text sit on its line?
h1 {
background-color: green;
font-size: 24px;
color: black;
text-align: right;
} (a) on the right (b) on the left (c) in the middle -
30.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 110px;
padding: 10px;
border: 1px solid black;
margin: 20px;
} - 31.🎯 Which element does the selector h2 style? (a) <li> (b) <div class="star"> (c) <h2 class="star"> (d) <span id="logo">
- 32.True or false: HTML gives the page structure. (a) True (b) False
- 33.True or false: HTML reacts to a button click. (a) False (b) True
- 34.What does font-family do? (a) colours behind the text (b) sets the letter colour (c) picks the font style (d) makes letters bigger
- 35.🎯 Which sign starts a class selector? (a) # (b) @ (c) & (d) .
-
36.⚖️ What colour is the text of this element?
<h2 class="menu" id="top">Hi</h2>
CSS:
h2 { color: white; }
h2 { color: blue; } (a) red (b) blue (c) white (d) green -
37.⚖️ What colour is the text of this element?
<p class="note" id="main">Hi</p>
CSS:
.note { color: blue; }
p { color: purple; } (a) yellow (b) purple (c) green (d) blue - 38.🎯 How many elements on a page should have the same id? (a) 2 (b) 5 (c) any number (d) 1
- 39.What does font-size do? (a) centres a heading (b) makes letters bigger (c) picks the font style (d) makes the text bold
-
40.✍️ What is the selector in this CSS rule?
h2 {
font-size: 20px;
font-style: italic;
} (a) font-size (b) h1 (c) italic (d) h2
Answer key
- True
- white
- Yes
- reacts to a button click
- JavaScript
- Yes
- False
- black
- display: flex
- equal gaps, none at ends
- align-items
- 314
- an id selector
- cyan
- black
- 800px or wider
- 16
- 19
- center
- text-align
- makes the text bold
- 40
- the screen width
- <h2 class="big">
- packs boxes at the start
- 80
- color
- #end
- on the right
- 172
- <h2 class="star">
- True
- False
- picks the font style
- .
- blue
- blue
- 1
- makes letters bigger
- h2
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids