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.🎨 A CSS file usually ends with which extension? (a) .css (b) .png (c) .html (d) .js
- 2.🔍 Which is the odd one out? (a) puts a picture on a page (b) makes headings and lists (c) shows a pop-up message (d) makes a form box
-
3.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 150px;
justify-content: space-between;
}
Inside are 2 boxes, each 60px wide (no margins). -
4.⚖️ What colour is the text of this element?
<h2 class="red" id="logo">Hi</h2>
CSS:
h2 { color: green; }
h2 { color: orange; } (a) purple (b) blue (c) orange (d) green - 5.✍️ Which sign goes between a property and its value? (a) = (b) - (c) : (d) ;
-
6.🖌️ What colour are the letters?
p {
color: red;
font-size: 32px;
background-color: black;
text-align: right;
} (a) red (b) yellow (c) black -
7.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 120px;
padding: 20px;
border: 2px solid black;
margin: 15px;
} - 8.🌈 In #00ec00 the green part is the hex number ec. What is it as a normal number?
- 9.True or false: CSS makes a link. (a) False (b) True
-
10.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 24px;
}
} (a) Yes (b) No - 11.✍️ In color: blue; which part is the value? (a) : (b) blue (c) ; (d) color
- 12.🌈 Which colour is #ffff00? (a) yellow (b) blue (c) red (d) cyan
- 13.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
-
14.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 170px;
justify-content: flex-end;
}
Inside are 3 boxes, each 40px wide (no margins). - 15.True or false: body is an element selector. (a) False (b) True
-
16.✍️ What is the selector in this CSS rule?
.note {
text-align: center;
font-weight: bold;
font-size: 20px;
margin: 10px;
} (a) bold (b) text-align (c) #top (d) .note -
17.🎯 Which CSS selector matches this element?
<div class="box" id="hero">Hello</div> (a) .hero (b) .star (c) span (d) div - 18.📦 In the box model, which part is the text or picture? (a) padding (b) border (c) content (d) margin
-
19.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 160px;
padding: 5px;
border: 4px solid black;
margin: 10px;
} - 20.What does font-family do? (a) makes letters bigger (b) picks the font style (c) colours behind the text (d) makes the text bold
-
21.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 480px) {
p {
font-size: 14px;
}
} (a) No (b) Yes - 22.What does font-size do? (a) centres a heading (b) makes letters bigger (c) picks the font style (d) makes the text bold
-
23.🖌️ What colour is behind the letters?
p {
background-color: red;
text-align: center;
color: purple;
font-size: 28px;
} (a) purple (b) red (c) blue - 24.🌈 In #3a0000 the red part is the hex number 3a. What is it as a normal number?
- 25.What does color do? (a) centres a heading (b) makes the text bold (c) sets the letter colour (d) makes letters bigger
- 26.📱 What does a media query check? (a) the battery level (b) the time of day (c) the page title (d) the screen width
- 27.What does font-weight do? (a) makes the text bold (b) centres a heading (c) makes letters bigger (d) sets the letter colour
-
28.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 22px;
}
} - 29.🎯 Which element does the selector #main style? (a) <h1 id="logo"> (b) <h1 id="main"> (c) <h2 class="red"> (d) <h1 class="main">
-
30.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 180px;
justify-content: center;
}
Inside are 2 boxes, each 50px wide (no margins). - 31.What does justify-content: space-between do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the start (d) packs boxes at the end
-
32.✍️ What value is given to color in this rule?
h1 {
font-weight: bold;
color: red;
} (a) center (b) 20px (c) red (d) color - 33.Which of these does JavaScript do? (a) gives the page structure (b) makes headings and lists (c) reacts to a button click (d) lays out the page
- 34.🎯 What kind of selector is .star? (a) an element selector (b) a class selector (c) an id selector
- 35.True or false: p is a class selector. (a) True (b) False
- 36.📱 Which tag helps phones show a page at the right size? (a) the br tag (b) the title tag (c) the viewport meta tag (d) the hr tag
- 37.✍️ Which sign ends each CSS declaration? (a) ; (b) : (c) . (d) ,
- 38.What does justify-content: flex-start do? (a) packs boxes at the start (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the end
-
39.⚖️ What colour is the text of this element?
<p class="box" id="hero">Hi</p>
CSS:
p { color: green; }
#hero { color: blue; }
.box { color: purple; } (a) orange (b) purple (c) blue (d) green -
40.✍️ What is the selector in this CSS rule?
p {
font-weight: bold;
width: 300px;
border: 2px solid;
background-color: yellow;
} (a) p (b) font-weight (c) 300px (d) .note
Answer key
- .css
- shows a pop-up message
- 30
- orange
- :
- red
- 194
- 236
- False
- Yes
- blue
- yellow
- an element selector
- 50
- True
- .note
- div
- content
- 178
- picks the font style
- Yes
- makes letters bigger
- red
- 58
- sets the letter colour
- the screen width
- makes the text bold
- 20
- <h1 id="main">
- 40
- equal gaps, none at ends
- red
- reacts to a button click
- a class selector
- False
- the viewport meta tag
- ;
- packs boxes at the start
- blue
- p
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids