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: JavaScript counts down a timer. (a) False (b) True
- 2.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
- 3.🌈 Which colour of light is strongest in rgb(31, 21, 219)? (a) red (b) blue (c) green
- 4.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) black (c) blue (d) red
- 5.🌈 What is the biggest number one colour can have in rgb()? (a) 100 (b) 1000 (c) 255 (d) 99
- 6.🧩 Which language adds space around boxes? (a) HTML (b) CSS (c) JavaScript
- 7.🎯 Which element does the selector #intro style? (a) <h1 id="main"> (b) <h2 class="note"> (c) <h1 class="intro"> (d) <h1 id="intro">
- 8.🔍 Which is the odd one out? (a) puts a picture on a page (b) gives the page structure (c) makes a link (d) sets colours and fonts
- 9.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the shorter one (c) neither (d) the later one
- 10.🌈 Which colour of light is strongest in rgb(195, 1, 120)? (a) blue (b) green (c) red
-
11.🎯 Which CSS selector matches this element?
<span class="note" id="top">Hello</span> (a) #note (b) p (c) #intro (d) .note -
12.⚖️ What colour is the text of this element?
<p class="red" id="logo">Hi</p>
CSS:
#logo { color: blue; }
#logo { color: orange; } (a) red (b) white (c) orange (d) blue - 13.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
-
14.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 80px;
padding: 10px;
border: 2px solid black;
margin: 15px;
} - 15.🧩 Which language shows a pop-up message? (a) JavaScript (b) HTML (c) CSS
- 16.🌈 Which colour is #ffff00? (a) magenta (b) blue (c) yellow (d) red
- 17.What does font-weight do? (a) makes letters bigger (b) colours behind the text (c) makes the text bold (d) sets the letter colour
- 18.True or false: margin is space inside the border. (a) False (b) True
- 19.📱 Which tag helps phones show a page at the right size? (a) the br tag (b) the viewport meta tag (c) the hr tag (d) the title tag
-
20.🖌️ What colour are the letters?
h2 {
background-color: white;
font-size: 20px;
text-align: left;
color: purple;
} (a) purple (b) white (c) green - 21.🌈 Which hex code is magenta? (a) #ff0000 (b) #ffffff (c) #00ffff (d) #ff00ff
- 22.🎯 Can many elements share the same class? (a) No (b) Yes
- 23.🌈 Which colour is rgb(0, 255, 255)? (a) magenta (b) bright green (c) black (d) cyan
- 24.🎯 What kind of selector is .card? (a) a class selector (b) an id selector (c) an element selector
-
25.⚖️ What colour is the text of this element?
<h2 class="menu" id="main">Hi</h2>
CSS:
#main { color: black; }
#main { color: green; } (a) purple (b) green (c) black (d) blue - 26.🎯 Which element does the selector .star style? (a) <div id="star"> (b) <div class="star"> (c) <span class="note"> (d) <div class="menu">
- 27.Which of these is margin? (a) space inside the border (b) the text or picture (c) the line round the box (d) the gap to other boxes
-
28.⚖️ What colour is the text of this element?
<h2 class="box" id="end">Hi</h2>
CSS:
.box { color: black; }
.box { color: orange; } (a) black (b) blue (c) orange (d) purple -
29.🖌️ Where does the text sit on its line?
h1 {
font-size: 32px;
color: blue;
background-color: green;
text-align: center;
} (a) on the right (b) on the left (c) in the middle -
30.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 180px;
justify-content: flex-end;
}
Inside are 2 boxes, each 60px wide (no margins). - 31.💪 Which justify-content value packs boxes at the start? (a) flex-end (b) space-between (c) center (d) flex-start
- 32.📱 max-width: 600px applies when the screen is ___. (a) 600px or narrower (b) turned off (c) 600px or wider (d) exactly 1000px
- 33.🌈 Which colour is rgb(255, 0, 0)? (a) blue (b) white (c) red (d) bright green
- 34.✍️ Which sign ends each CSS declaration? (a) ; (b) , (c) : (d) .
-
35.✍️ Which property is set to bold in this rule?
p {
font-weight: bold;
background-color: yellow;
} (a) font-weight (b) bold (c) border (d) width - 36.🌈 Which colour is #ff00ff? (a) bright green (b) black (c) magenta (d) yellow
- 37.🌈 Which colour is #ff0000? (a) yellow (b) white (c) red (d) magenta
- 38.Which of these does CSS do? (a) shows a pop-up message (b) checks a quiz answer (c) adds space around boxes (d) changes the page live
-
39.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 320px;
justify-content: flex-end;
}
Inside are 4 boxes, each 60px wide (no margins). -
40.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 190px;
padding: 5px;
border: 5px solid black;
margin: 0px;
}
Answer key
- True
- an element selector
- blue
- red
- 255
- CSS
- <h1 id="intro">
- sets colours and fonts
- the later one
- red
- .note
- orange
- an id selector
- 134
- JavaScript
- yellow
- makes the text bold
- False
- the viewport meta tag
- purple
- #ff00ff
- Yes
- cyan
- a class selector
- green
- <div class="star">
- the gap to other boxes
- orange
- in the middle
- 60
- flex-start
- 600px or narrower
- red
- ;
- font-weight
- magenta
- red
- adds space around boxes
- 80
- 210
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids