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.🎯 Which sign starts a class selector? (a) # (b) & (c) @ (d) .
- 2.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the viewport meta tag (c) the br tag (d) the hr tag
- 3.True or false: the border is the line round the box. (a) True (b) False
-
4.🎯 Which CSS selector matches this element?
<h2 class="red" id="hero">Hello</h2> (a) li (b) #top (c) .red (d) #red - 5.🌈 Which hex code is bright green? (a) #0000ff (b) #ffffff (c) #ff00ff (d) #00ff00
- 6.✍️ In color: blue; which part is the property? (a) ; (b) color (c) : (d) blue
- 7.✍️ Which sign ends each CSS declaration? (a) , (b) . (c) ; (d) :
- 8.Which of these does HTML do? (a) adds space around boxes (b) lays out the page (c) puts a picture on a page (d) counts down a timer
- 9.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
-
10.⚖️ What colour is the text of this element?
<h1 class="box" id="main">Hi</h1>
CSS:
#main { color: red; }
#main { color: green; } (a) green (b) yellow (c) white (d) red - 11.🧩 Which language adds space around boxes? (a) JavaScript (b) CSS (c) HTML
- 12.✍️ How does a CSS comment start? (a) <!-- (b) /* (c) // (d) #
- 13.🎯 Which element does the selector h1 style? (a) <div id="intro"> (b) <h1 class="star"> (c) <h2> (d) <li class="star">
- 14.🌈 Which hex code is magenta? (a) #ff0000 (b) #ff00ff (c) #0000ff (d) #000000
- 15.What does justify-content: space-between do? (a) puts boxes in the middle (b) packs boxes at the end (c) equal gaps, none at ends (d) packs boxes at the start
-
16.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 3 boxes, each 80px wide (no margins). - 17.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) turned off (c) exactly 100px (d) 800px or wider
- 18.💪 Which flexbox property spaces boxes along a row? (a) flex-direction (b) justify-content (c) align-items (d) gap
- 19.Which of these does HTML do? (a) changes the page live (b) makes a form box (c) adds space around boxes (d) counts down a timer
-
20.⚖️ What colour is the text of this element?
<h2 class="menu" id="top">Hi</h2>
CSS:
h2 { color: red; }
h2 { color: green; } (a) green (b) blue (c) yellow (d) red -
21.🖌️ Where does the text sit on its line?
h2 {
font-size: 16px;
color: yellow;
background-color: blue;
text-align: left;
} (a) on the left (b) on the right (c) in the middle - 22.🎯 Which element does the selector #main style? (a) <div class="main"> (b) <div id="logo"> (c) <span class="box"> (d) <div id="main">
- 23.🌈 Which colour is #ff00ff? (a) bright green (b) magenta (c) blue (d) red
- 24.🌈 Which colour is #ffffff? (a) blue (b) magenta (c) red (d) white
- 25.🔍 Which is the odd one out? (a) lays out the page (b) changes the text size (c) changes the page live (d) rounds box corners
-
26.⚖️ What colour is the text of this element?
<h1 class="big" id="logo">Hi</h1>
CSS:
h1 { color: red; }
h1 { color: orange; } (a) orange (b) red (c) yellow (d) black - 27.🧩 Which language puts a picture on a page? (a) CSS (b) JavaScript (c) HTML
-
28.🖌️ How big is the text, in px?
p {
background-color: orange;
font-size: 36px;
color: red;
text-align: right;
} - 29.🔍 Which is the odd one out? (a) sets colours and fonts (b) checks a quiz answer (c) shows a pop-up message (d) counts down a timer
- 30.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) blue (c) red (d) white
- 31.🎯 What kind of selector is h1? (a) an id selector (b) an element selector (c) a class selector
- 32.True or false: HTML puts a picture on a page. (a) True (b) False
-
33.⚖️ What colour is the text of this element?
<p class="box" id="intro">Hi</p>
CSS:
.box { color: red; }
.box { color: black; } (a) yellow (b) black (c) white (d) red - 34.🎯 What kind of selector is .big? (a) a class selector (b) an element selector (c) an id selector
- 35.What does justify-content: flex-end do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the end (d) packs boxes at the start
-
36.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 50px;
padding: 20px;
border: 3px solid black;
margin: 15px;
} - 37.🖌️ Which CSS property centres a heading? (a) background-color (b) font-size (c) text-align (d) font-family
- 38.True or false: HTML sets colours and fonts. (a) True (b) False
-
39.⚖️ What colour is the text of this element?
<h1 class="red" id="main">Hi</h1>
CSS:
.red { color: red; }
.red { color: blue; } (a) black (b) red (c) white (d) blue -
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: 280px;
padding: 5px;
border: 5px solid black;
margin: 15px;
}
Answer key
- .
- the viewport meta tag
- True
- .red
- #00ff00
- color
- ;
- puts a picture on a page
- an element selector
- green
- CSS
- /*
- <h1 class="star">
- #ff00ff
- equal gaps, none at ends
- 10
- 800px or wider
- justify-content
- makes a form box
- green
- on the left
- <div id="main">
- magenta
- white
- changes the page live
- orange
- HTML
- 36
- sets colours and fonts
- blue
- an element selector
- True
- black
- a class selector
- packs boxes at the end
- 126
- text-align
- False
- blue
- 300
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids