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 element does the selector #main style? (a) <span id="logo"> (b) <span id="main"> (c) <p class="menu"> (d) <span class="main">
-
2.✍️ What is the selector in this CSS rule?
#top {
font-style: italic;
margin: 10px;
padding: 8px;
} (a) #top (b) font-style (c) li (d) 10px - 3.📦 In the box model, which part is the text or picture? (a) border (b) margin (c) content (d) padding
-
4.✍️ What is the selector in this CSS rule?
li {
width: 300px;
background-color: yellow;
font-size: 20px;
text-align: center;
} (a) yellow (b) width (c) body (d) li - 5.🖌️ Which CSS property centres a heading? (a) font-size (b) text-align (c) background-color (d) font-family
-
6.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 8px;
}
} -
7.✍️ How many declarations (property: value pairs) are in this rule?
.note {
border: 2px solid;
margin: 10px;
} - 8.🎯 How many elements on a page should have the same id? (a) any number (b) 1 (c) 5 (d) 2
-
9.🖌️ What colour are the letters?
h1 {
background-color: blue;
color: green;
font-size: 32px;
text-align: left;
} (a) yellow (b) green (c) blue - 10.✍️ In color: blue; which part is the property? (a) blue (b) : (c) color (d) ;
- 11.True or false: JavaScript sets colours and fonts. (a) True (b) False
-
12.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 300px;
justify-content: center;
}
Inside are 3 boxes, each 60px wide (no margins). - 13.Which of these does JavaScript do? (a) adds space around boxes (b) puts a picture on a page (c) shows a pop-up message (d) sets colours and fonts
- 14.🔍 Which is the odd one out? (a) shows a pop-up message (b) puts a picture on a page (c) changes the page live (d) counts down a timer
- 15.🌈 Which colour is rgb(255, 0, 255)? (a) cyan (b) blue (c) yellow (d) magenta
-
16.⚖️ What colour is the text of this element?
<p class="star" id="intro">Hi</p>
CSS:
p { color: green; }
p { color: purple; } (a) blue (b) red (c) green (d) purple - 17.🖌️ Which CSS property sets the letter colour? (a) font-family (b) color (c) text-align (d) font-weight
-
18.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 1024px) {
p {
font-size: 24px;
}
} - 19.🧩 Which language reacts to a button click? (a) CSS (b) JavaScript (c) HTML
- 20.What does font-weight do? (a) picks the font style (b) makes the text bold (c) centres a heading (d) colours behind the text
- 21.🎯 Which sign starts an id selector? (a) @ (b) & (c) . (d) #
- 22.Which of these does HTML do? (a) rounds box corners (b) gives the page structure (c) reacts to a button click (d) adds space around boxes
-
23.⚖️ What colour is the text of this element?
<h1 class="red" id="intro">Hi</h1>
CSS:
.red { color: blue; }
#intro { color: orange; } (a) orange (b) blue (c) yellow (d) red - 24.🎯 Which element does the selector .red style? (a) <p class="red"> (b) <p class="box"> (c) <p id="red"> (d) <h1 class="star">
- 25.🌈 Which colour is rgb(0, 255, 255)? (a) yellow (b) cyan (c) bright green (d) red
-
26.🖌️ How big is the text, in px?
h1 {
color: black;
font-size: 40px;
background-color: white;
text-align: center;
} -
27.🖌️ How big is the text, in px?
p {
background-color: purple;
font-size: 40px;
color: red;
text-align: center;
} - 28.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the viewport meta tag (c) the hr tag (d) the br tag
- 29.🔍 Which is the odd one out? (a) counts down a timer (b) changes the text size (c) adds space around boxes (d) sets colours and fonts
- 30.📦 In the box model, which part is the gap to other boxes? (a) padding (b) margin (c) border (d) content
- 31.🧩 Which language makes a link? (a) JavaScript (b) CSS (c) HTML
-
32.✍️ Which property is set to center in this rule?
.note {
width: 300px;
text-align: center;
} (a) background-color (b) text-align (c) margin (d) center - 33.📦 In the box model, which part is a solid or dotted edge? (a) margin (b) content (c) padding (d) border
-
34.✍️ Which property is set to 10px in this rule?
h2 {
padding: 8px;
background-color: yellow;
margin: 10px;
width: 300px;
} (a) margin (b) 10px (c) padding (d) font-weight - 35.True or false: padding is a solid or dotted edge. (a) True (b) False
- 36.True or false: .big is a class selector. (a) False (b) True
-
37.⚖️ What colour is the text of this element?
<h1 class="box" id="top">Hi</h1>
CSS:
.box { color: green; }
#top { color: blue; }
h1 { color: white; } (a) white (b) blue (c) green (d) purple - 38.What does font-size do? (a) picks the font style (b) colours behind the text (c) centres a heading (d) makes letters bigger
- 39.🧩 Which language adds space around boxes? (a) JavaScript (b) CSS (c) HTML
-
40.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 120px;
justify-content: flex-end;
}
Inside are 2 boxes, each 40px wide (no margins).
Answer key
- <span id="main">
- #top
- content
- li
- text-align
- 8
- 2
- 1
- green
- color
- False
- 60
- shows a pop-up message
- puts a picture on a page
- magenta
- purple
- color
- 20
- JavaScript
- makes the text bold
- #
- gives the page structure
- orange
- <p class="red">
- cyan
- 40
- 40
- the viewport meta tag
- counts down a timer
- margin
- HTML
- text-align
- border
- margin
- False
- True
- blue
- makes letters bigger
- CSS
- 40
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids