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.🎯 What kind of selector is li? (a) an id selector (b) an element selector (c) a class selector
- 2.💪 Which flexbox property lines boxes up across? (a) display: flex (b) align-items (c) gap (d) justify-content
-
3.🖌️ Where does the text sit on its line?
h1 {
background-color: white;
text-align: left;
color: yellow;
font-size: 24px;
} (a) in the middle (b) on the left (c) on the right - 4.True or false: HTML makes a form box. (a) False (b) True
- 5.🎯 Which element does the selector p style? (a) <h2 class="red"> (b) <p class="red"> (c) <h1> (d) <li id="logo">
-
6.⚖️ What colour is the text of this element?
<h1 class="big" id="top">Hi</h1>
CSS:
#top { color: green; }
#top { color: red; } (a) black (b) orange (c) green (d) red - 7.💪 Which justify-content value packs boxes at the start? (a) flex-start (b) space-between (c) center (d) flex-end
- 8.True or false: .big is a class selector. (a) False (b) True
-
9.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 250px;
padding: 30px;
border: 1px solid black;
margin: 15px;
} - 10.✍️ How does a CSS comment start? (a) /* (b) # (c) <!-- (d) //
-
11.⚖️ What colour is the text of this element?
<h1 class="red" id="logo">Hi</h1>
CSS:
.red { color: blue; }
.red { color: red; } (a) yellow (b) blue (c) orange (d) red - 12.🎯 Can many elements share the same class? (a) No (b) Yes
- 13.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 6 (b) 4 (c) 3 (d) 2
- 14.True or false: padding is space inside the border. (a) True (b) False
-
15.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 18px;
}
} (a) No (b) Yes - 16.What does color do? (a) picks the font style (b) colours behind the text (c) centres a heading (d) sets the letter colour
-
17.✍️ What is the selector in this CSS rule?
.note {
border: 2px solid;
padding: 8px;
} (a) border (b) #top (c) 8px (d) .note - 18.🌈 In #000200 the green part is the hex number 02. What is it as a normal number?
- 19.🧩 Which language shows a pop-up message? (a) HTML (b) JavaScript (c) CSS
-
20.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 768px) {
p {
font-size: 28px;
}
} - 21.True or false: CSS changes the page live. (a) False (b) True
-
22.⚖️ What colour is the text of this element?
<h1 class="big" id="intro">Hi</h1>
CSS:
#intro { color: red; }
.big { color: yellow; } (a) yellow (b) purple (c) orange (d) red -
23.✍️ Which property is set to 2px solid in this rule?
.box {
font-size: 20px;
width: 300px;
color: red;
border: 2px solid;
} (a) font-style (b) width (c) 2px solid (d) border -
24.⚖️ What colour is the text of this element?
<h2 class="box" id="main">Hi</h2>
CSS:
#main { color: black; }
h2 { color: yellow; } (a) black (b) green (c) yellow (d) purple - 25.True or false: h1 is an id selector. (a) True (b) False
- 26.True or false: margin is the gap round content. (a) False (b) True
- 27.What does justify-content: flex-start do? (a) packs boxes at the end (b) equal gaps, none at ends (c) packs boxes at the start (d) puts boxes in the middle
-
28.🎯 Which CSS selector matches this element?
<h1 class="star" id="intro">Hello</h1> (a) .menu (b) h2 (c) .star (d) #main -
29.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 190px;
justify-content: flex-end;
}
Inside are 4 boxes, each 40px wide (no margins). - 30.✍️ In color: blue; which part is the property? (a) color (b) : (c) ; (d) blue
- 31.🎯 What kind of selector is .star? (a) a class selector (b) an element selector (c) an id selector
- 32.True or false: JavaScript rounds box corners. (a) False (b) True
-
33.⚖️ What colour is the text of this element?
<p class="note" id="logo">Hi</p>
CSS:
p { color: orange; }
p { color: red; } (a) blue (b) red (c) orange (d) purple -
34.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 10px;
}
} (a) Yes (b) No - 35.Which of these is margin? (a) a solid or dotted edge (b) space outside the border (c) the gap round content (d) the text or picture
- 36.True or false: padding is the gap round content. (a) False (b) True
-
37.🖌️ Where does the text sit on its line?
li {
background-color: black;
color: red;
text-align: left;
font-size: 24px;
} (a) in the middle (b) on the left (c) on the right - 38.✍️ Which sign goes between a property and its value? (a) ; (b) - (c) = (d) :
- 39.Which of these does HTML do? (a) rounds box corners (b) makes headings and lists (c) shows a pop-up message (d) reacts to a button click
-
40.⚖️ What colour is the text of this element?
<p class="red" id="intro">Hi</p>
CSS:
.red { color: yellow; }
.red { color: white; } (a) yellow (b) green (c) orange (d) white
Answer key
- an element selector
- align-items
- on the left
- True
- <p class="red">
- red
- flex-start
- True
- 342
- /*
- red
- Yes
- 3
- True
- No
- sets the letter colour
- .note
- 2
- JavaScript
- 24
- False
- red
- border
- black
- False
- False
- packs boxes at the start
- .star
- 30
- color
- a class selector
- False
- red
- Yes
- space outside the border
- True
- on the left
- :
- makes headings and lists
- white
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids