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 selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
-
2.⚖️ What colour is the text of this element?
<p class="star" id="hero">Hi</p>
CSS:
p { color: red; }
p { color: green; } (a) red (b) green (c) white (d) blue -
3.✍️ What value is given to font-weight in this rule?
.note {
font-weight: bold;
background-color: yellow;
} (a) 2px solid (b) bold (c) font-weight (d) 300px -
4.✍️ What is the selector in this CSS rule?
#top {
width: 300px;
font-style: italic;
} (a) #top (b) italic (c) li (d) width -
5.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 180px;
padding: 25px;
border: 2px solid black;
margin: 20px;
} - 6.✍️ How does a CSS comment start? (a) // (b) # (c) /* (d) <!--
- 7.🎯 Which element does the selector .box style? (a) <p class="menu"> (b) <span id="box"> (c) <span class="star"> (d) <span class="box">
- 8.✍️ Which sign goes between a property and its value? (a) ; (b) - (c) = (d) :
-
9.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 140px;
padding: 15px;
border: 2px solid black;
margin: 10px;
} - 10.🔍 Which is the odd one out? (a) makes a form box (b) changes the text size (c) puts a picture on a page (d) makes a link
- 11.True or false: JavaScript gives the page structure. (a) False (b) True
- 12.📱 What does a media query check? (a) the page title (b) the time of day (c) the screen width (d) the battery level
- 13.🖌️ Which CSS property picks the font style? (a) font-size (b) text-align (c) font-family (d) color
-
14.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 24px;
}
} (a) No (b) Yes -
15.⚖️ What colour is the text of this element?
<h2 class="box" id="end">Hi</h2>
CSS:
h2 { color: yellow; }
#end { color: orange; } (a) black (b) green (c) yellow (d) orange -
16.✍️ What is the selector in this CSS rule?
.note {
background-color: yellow;
font-weight: bold;
color: red;
} (a) bold (b) .note (c) #top (d) background-color - 17.True or false: CSS changes the text size. (a) False (b) True
-
18.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 24px;
}
} - 19.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) white (c) red (d) green
-
20.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 16px;
}
} -
21.✍️ What is the selector in this CSS rule?
li {
text-align: center;
padding: 8px;
font-size: 20px;
} (a) 8px (b) body (c) text-align (d) li - 22.True or false: JavaScript makes a form box. (a) False (b) True
- 23.🖌️ Which CSS property makes the text bold? (a) text-align (b) font-weight (c) color (d) font-size
-
24.⚖️ What colour is the text of this element?
<h1 class="red" id="main">Hi</h1>
CSS:
#main { color: black; }
.red { color: blue; } (a) blue (b) purple (c) green (d) black -
25.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 22px;
}
} -
26.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 230px;
justify-content: flex-start;
}
Inside are 2 boxes, each 100px wide (no margins). - 27.🌈 Which colour is #ffffff? (a) bright green (b) white (c) black (d) red
- 28.💪 Which flexbox property lines boxes up across? (a) gap (b) display: flex (c) align-items (d) flex-direction
- 29.🌈 Which colour is #0000ff? (a) bright green (b) blue (c) cyan (d) yellow
- 30.💪 Which flexbox property picks row or column? (a) justify-content (b) flex-direction (c) align-items (d) display: flex
- 31.🎯 What kind of selector is #logo? (a) an element selector (b) an id selector (c) a class selector
- 32.💪 Which flexbox property sets space between boxes? (a) display: flex (b) align-items (c) flex-direction (d) gap
- 33.✍️ In color: blue; which part is the value? (a) : (b) ; (c) blue (d) color
- 34.True or false: CSS sets colours and fonts. (a) False (b) True
-
35.🖌️ What colour is behind the letters?
li {
color: red;
font-size: 24px;
text-align: right;
background-color: white;
} (a) white (b) blue (c) red -
36.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 100px;
padding: 20px;
border: 4px solid black;
margin: 15px;
} - 37.🌈 In #2f0000 the red part is the hex number 2f. What is it as a normal number?
- 38.🔍 Which is the odd one out? (a) gives the page structure (b) puts a picture on a page (c) makes headings and lists (d) changes the page live
- 39.🧩 Which language makes a link? (a) CSS (b) HTML (c) JavaScript
- 40.📦 In the box model, which part is the text or picture? (a) padding (b) content (c) border (d) margin
Answer key
- an element selector
- green
- bold
- #top
- 274
- /*
- <span class="box">
- :
- 194
- changes the text size
- False
- the screen width
- font-family
- Yes
- orange
- .note
- True
- 24
- blue
- 12
- li
- False
- font-weight
- black
- 24
- 30
- white
- align-items
- blue
- flex-direction
- an id selector
- gap
- blue
- True
- white
- 178
- 47
- changes the page live
- HTML
- content
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids