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.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the later one (c) neither (d) the first one
- 2.True or false: JavaScript reacts to a button click. (a) False (b) True
-
3.🖌️ What colour is behind the letters?
h1 {
font-size: 24px;
color: blue;
text-align: left;
background-color: white;
} (a) yellow (b) white (c) blue - 4.🔍 Which is the odd one out? (a) sets colours and fonts (b) counts down a timer (c) lays out the page (d) changes the text size
-
5.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 8px;
}
} (a) No (b) Yes - 6.What does font-size do? (a) makes letters bigger (b) makes the text bold (c) picks the font style (d) centres a heading
-
7.✍️ Which property is set to red in this rule?
.note {
font-weight: bold;
font-size: 20px;
width: 300px;
color: red;
} (a) font-size (b) red (c) text-align (d) color -
8.🖌️ Where does the text sit on its line?
p {
text-align: left;
font-size: 24px;
color: blue;
background-color: red;
} (a) on the left (b) in the middle (c) on the right - 9.💪 Which justify-content value packs boxes at the start? (a) center (b) flex-start (c) space-between (d) flex-end
- 10.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
- 11.🧩 Which language puts a picture on a page? (a) JavaScript (b) CSS (c) HTML
-
12.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 90px;
padding: 15px;
border: 4px solid black;
margin: 20px;
} - 13.True or false: JavaScript changes the page live. (a) True (b) False
- 14.True or false: CSS sets colours and fonts. (a) False (b) True
- 15.🌈 Which colour is #ffffff? (a) white (b) black (c) cyan (d) bright green
- 16.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) turned off (c) 600px or wider (d) 600px or narrower
- 17.🎯 What kind of selector is .big? (a) a class selector (b) an element selector (c) an id selector
- 18.🔍 Which is the odd one out? (a) makes a form box (b) makes headings and lists (c) makes a link (d) changes the page live
- 19.🌈 Which colour of light is strongest in rgb(105, 237, 106)? (a) red (b) blue (c) green
- 20.🌈 Which colour is #00ff00? (a) yellow (b) black (c) white (d) bright green
- 21.✍️ Which sign ends each CSS declaration? (a) : (b) ; (c) , (d) .
- 22.🖌️ Which CSS property colours behind the text? (a) color (b) text-align (c) background-color (d) font-weight
- 23.💪 Which justify-content value equal gaps, none at ends? (a) flex-end (b) space-between (c) center (d) flex-start
-
24.✍️ What is the selector in this CSS rule?
li {
color: red;
margin: 10px;
} (a) 10px (b) color (c) body (d) li -
25.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 22px;
}
} - 26.🎯 What kind of selector is #end? (a) an element selector (b) a class selector (c) an id selector
-
27.🖌️ What colour is behind the letters?
p {
font-size: 12px;
color: yellow;
background-color: blue;
text-align: right;
} (a) yellow (b) black (c) blue - 28.What does justify-content: center do? (a) packs boxes at the end (b) packs boxes at the start (c) equal gaps, none at ends (d) puts boxes in the middle
- 29.💪 Which flexbox property picks row or column? (a) justify-content (b) display: flex (c) align-items (d) flex-direction
-
30.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 260px;
justify-content: flex-start;
}
Inside are 4 boxes, each 50px wide (no margins). -
31.⚖️ What colour is the text of this element?
<h2 class="note" id="intro">Hi</h2>
CSS:
.note { color: orange; }
.note { color: blue; } (a) orange (b) blue (c) purple (d) red -
32.🎯 Which CSS selector matches this element?
<h1 class="box" id="logo">Hello</h1> (a) #box (b) h1 (c) #end (d) .logo -
33.✍️ What value is given to width in this rule?
.note {
padding: 8px;
font-style: italic;
margin: 10px;
width: 300px;
} (a) width (b) italic (c) red (d) 300px - 34.🎨 Which tag holds CSS inside the head? (a) <body> (b) <css> (c) <style> (d) <script>
- 35.🖌️ Which CSS property sets the letter colour? (a) font-weight (b) background-color (c) color (d) font-size
-
36.💪 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 60px wide (no margins). -
37.⚖️ What colour is the text of this element?
<h2 class="big" id="end">Hi</h2>
CSS:
.big { color: orange; }
h2 { color: black; }
#end { color: white; } (a) green (b) black (c) white (d) orange -
38.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 170px;
justify-content: space-between;
}
Inside are 2 boxes, each 80px wide (no margins). - 39.🎯 What kind of selector is #hero? (a) an id selector (b) a class selector (c) an element selector
- 40.🌈 Which colour is rgb(0, 0, 255)? (a) blue (b) black (c) magenta (d) red
Answer key
- the later one
- True
- white
- counts down a timer
- Yes
- makes letters bigger
- color
- on the left
- flex-start
- an id selector
- HTML
- 168
- True
- True
- white
- 600px or narrower
- a class selector
- changes the page live
- green
- bright green
- ;
- background-color
- space-between
- li
- 24
- an id selector
- blue
- puts boxes in the middle
- flex-direction
- 60
- blue
- h1
- 300px
- <style>
- color
- 30
- white
- 10
- an id selector
- blue
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids