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 ends each CSS declaration? (a) . (b) ; (c) : (d) ,
- 2.🎨 Which tag holds CSS inside the head? (a) <style> (b) <css> (c) <script> (d) <body>
- 3.🌈 Which hex code is cyan? (a) #00ffff (b) #0000ff (c) #ffffff (d) #ff00ff
- 4.🎯 What kind of selector is #end? (a) an id selector (b) an element selector (c) a class selector
- 5.🌈 Which colour is #000000? (a) red (b) black (c) bright green (d) magenta
-
6.🖌️ What colour is behind the letters?
p {
text-align: right;
font-size: 36px;
color: yellow;
background-color: red;
} (a) white (b) red (c) yellow -
7.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 200px;
justify-content: flex-end;
}
Inside are 4 boxes, each 40px wide (no margins). - 8.✍️ How does a CSS comment start? (a) // (b) /* (c) # (d) <!--
- 9.📱 Responsive design means a page ___. (a) never changes (b) has no pictures (c) is only for laptops (d) fits every screen
-
10.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 14px;
}
} - 11.⚖️ Which selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
- 12.🎯 Which element does the selector h1 style? (a) <li class="star"> (b) <h1 class="star"> (c) <div id="hero"> (d) <h2>
- 13.True or false: CSS makes headings and lists. (a) False (b) True
-
14.✍️ What is the selector in this CSS rule?
p {
color: red;
width: 300px;
border: 2px solid;
} (a) color (b) p (c) 300px (d) .note -
15.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 20px;
}
} (a) Yes (b) No -
16.⚖️ What colour is the text of this element?
<p class="big" id="intro">Hi</p>
CSS:
p { color: yellow; }
p { color: green; } (a) purple (b) white (c) green (d) yellow - 17.True or false: CSS reacts to a button click. (a) False (b) True
- 18.What does font-weight do? (a) makes the text bold (b) picks the font style (c) centres a heading (d) colours behind the text
- 19.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) neither (c) the later one (d) the shorter one
-
20.⚖️ What colour is the text of this element?
<p class="red" id="top">Hi</p>
CSS:
p { color: yellow; }
p { color: blue; } (a) purple (b) yellow (c) blue (d) green -
21.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 300px;
padding: 20px;
border: 1px solid black;
margin: 0px;
} -
22.⚖️ What colour is the text of this element?
<p class="note" id="top">Hi</p>
CSS:
.note { color: green; }
.note { color: blue; } (a) red (b) orange (c) green (d) blue -
23.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 1024px) {
p {
font-size: 22px;
}
} (a) No (b) Yes - 24.🌈 Which colour is rgb(255, 0, 0)? (a) white (b) red (c) yellow (d) cyan
- 25.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) turned off (c) exactly 100px (d) 800px or wider
-
26.⚖️ What colour is the text of this element?
<h2 class="menu" id="top">Hi</h2>
CSS:
#top { color: purple; }
#top { color: white; } (a) blue (b) white (c) purple (d) black - 27.🖌️ Which CSS property centres a heading? (a) font-family (b) text-align (c) background-color (d) font-size
-
28.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 120px;
padding: 5px;
border: 4px solid black;
margin: 15px;
} -
29.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 20px;
}
} (a) Yes (b) No - 30.💪 Which justify-content value packs boxes at the start? (a) flex-end (b) center (c) space-between (d) flex-start
-
31.🎯 Which CSS selector matches this element?
<p class="big" id="top">Hello</p> (a) #big (b) #intro (c) #top (d) .red -
32.✍️ How many declarations (property: value pairs) are in this rule?
.note {
width: 300px;
} - 33.🎯 What kind of selector is .menu? (a) a class selector (b) an id selector (c) an element selector
- 34.🎯 What kind of selector is #main? (a) a class selector (b) an element selector (c) an id selector
- 35.🌈 Which hex code is yellow? (a) #ff0000 (b) #ffff00 (c) #0000ff (d) #ff00ff
- 36.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
-
37.✍️ How many declarations (property: value pairs) are in this rule?
.note {
margin: 10px;
font-style: italic;
font-weight: bold;
} - 38.🔍 Which is the odd one out? (a) rounds box corners (b) lays out the page (c) sets colours and fonts (d) changes the page live
- 39.🎯 How many elements on a page should have the same id? (a) 5 (b) 2 (c) any number (d) 1
- 40.True or false: .menu is a class selector. (a) True (b) False
Answer key
- ;
- <style>
- #00ffff
- an id selector
- black
- red
- 40
- /*
- fits every screen
- 14
- an id selector
- <h1 class="star">
- False
- p
- No
- green
- False
- makes the text bold
- the later one
- blue
- 342
- blue
- Yes
- red
- 800px or wider
- white
- text-align
- 138
- Yes
- flex-start
- #top
- 1
- a class selector
- an id selector
- #ffff00
- an element selector
- 3
- changes the page live
- 1
- True
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids