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.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 110px;
padding: 30px;
border: 2px solid black;
margin: 5px;
} -
2.🎯 Which CSS selector matches this element?
<h2 class="star" id="main">Hello</h2> (a) .star (b) .menu (c) #star (d) li -
3.⚖️ What colour is the text of this element?
<h2 class="star" id="logo">Hi</h2>
CSS:
#logo { color: yellow; }
#logo { color: blue; } (a) green (b) blue (c) purple (d) yellow - 4.True or false: .card is a class selector. (a) True (b) False
-
5.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 100px;
padding: 15px;
border: 4px solid black;
margin: 15px;
} - 6.✍️ In color: blue; which part is the value? (a) ; (b) : (c) color (d) blue
- 7.🎯 Which element does the selector #main style? (a) <h2 class="main"> (b) <h2 id="logo"> (c) <li class="box"> (d) <h2 id="main">
- 8.🖌️ Which CSS property colours behind the text? (a) color (b) font-size (c) background-color (d) font-weight
-
9.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} (a) Yes (b) No - 10.🌈 Which colour is #00ffff? (a) black (b) red (c) cyan (d) yellow
- 11.🌈 In #007200 the green part is the hex number 72. What is it as a normal number?
- 12.🎯 How many elements on a page should have the same id? (a) 1 (b) any number (c) 2 (d) 5
- 13.💪 Which flexbox property spaces boxes along a row? (a) display: flex (b) gap (c) justify-content (d) flex-direction
-
14.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 140px;
padding: 30px;
border: 5px solid black;
margin: 10px;
} -
15.✍️ Which property is set to 300px in this rule?
#top {
font-style: italic;
width: 300px;
} (a) 300px (b) font-style (c) color (d) width - 16.True or false: padding is the gap round content. (a) False (b) True
- 17.✍️ Which sign goes between a property and its value? (a) ; (b) - (c) = (d) :
-
18.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 32px;
}
} -
19.⚖️ What colour is the text of this element?
<h2 class="box" id="top">Hi</h2>
CSS:
h2 { color: orange; }
#top { color: blue; } (a) blue (b) orange (c) purple (d) green - 20.🎯 What kind of selector is .star? (a) an id selector (b) an element selector (c) a class selector
-
21.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 250px;
justify-content: flex-start;
}
Inside are 2 boxes, each 100px wide (no margins). - 22.🌈 In #c20000 the red part is the hex number c2. What is it as a normal number?
- 23.🎯 What kind of selector is #end? (a) a class selector (b) an id selector (c) an element selector
-
24.⚖️ What colour is the text of this element?
<p class="note" id="logo">Hi</p>
CSS:
p { color: black; }
#logo { color: white; }
.note { color: blue; } (a) yellow (b) white (c) black (d) blue - 25.🎯 Which element does the selector h2 style? (a) <span id="end"> (b) <li> (c) <h2 class="note"> (d) <div class="note">
- 26.🎨 One CSS file can style how many pages? (a) only one image (b) only one word (c) no pages (d) many pages
-
27.⚖️ What colour is the text of this element?
<p class="box" id="main">Hi</p>
CSS:
p { color: red; }
.box { color: green; }
#main { color: white; } (a) black (b) green (c) white (d) red - 28.True or false: HTML lays out the page. (a) False (b) True
-
29.⚖️ What colour is the text of this element?
<h2 class="box" id="logo">Hi</h2>
CSS:
h2 { color: orange; }
h2 { color: yellow; } (a) blue (b) orange (c) white (d) yellow - 30.🎯 Can many elements share the same class? (a) No (b) Yes
-
31.✍️ Which property is set to bold in this rule?
body {
padding: 8px;
font-weight: bold;
border: 2px solid;
} (a) font-weight (b) border (c) bold (d) width - 32.🧩 Which language puts a picture on a page? (a) CSS (b) HTML (c) JavaScript
- 33.True or false: HTML shows a pop-up message. (a) True (b) False
- 34.✍️ CSS declarations go inside which brackets? (a) ( ) (b) [ ] (c) < > (d) { }
-
35.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
font-size: 20px;
text-align: center;
} - 36.💪 Which justify-content value packs boxes at the start? (a) flex-end (b) center (c) space-between (d) flex-start
-
37.🖌️ What colour are the letters?
p {
color: black;
background-color: white;
font-size: 20px;
text-align: right;
} (a) white (b) black (c) orange - 38.🌈 Which colour is rgb(0, 0, 255)? (a) blue (b) red (c) white (d) yellow
- 39.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) exactly 1000px (c) 600px or narrower (d) turned off
-
40.✍️ How many declarations (property: value pairs) are in this rule?
li {
text-align: center;
font-size: 20px;
}
Answer key
- 174
- .star
- blue
- True
- 168
- blue
- <h2 id="main">
- background-color
- No
- cyan
- 114
- 1
- justify-content
- 230
- width
- True
- :
- 24
- blue
- a class selector
- 50
- 194
- an id selector
- white
- <h2 class="note">
- many pages
- white
- False
- yellow
- Yes
- font-weight
- HTML
- False
- { }
- 2
- flex-start
- black
- blue
- 600px or narrower
- 2
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids