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 does text-align do? (a) makes the text bold (b) centres a heading (c) colours behind the text (d) picks the font style
-
2.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 50px;
padding: 10px;
border: 3px solid black;
margin: 20px;
} -
3.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 240px;
justify-content: center;
}
Inside are 3 boxes, each 60px wide (no margins). -
4.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-size: 20px;
margin: 10px;
font-weight: bold;
} -
5.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 260px;
padding: 5px;
border: 1px solid black;
margin: 5px;
} - 6.🌈 Which colour of light is strongest in rgb(12, 105, 193)? (a) blue (b) red (c) green
- 7.🎯 What kind of selector is .note? (a) an element selector (b) an id selector (c) a class selector
- 8.🌈 In #rrggbb, which colour do the first two digits give? (a) red (b) blue (c) green (d) black
- 9.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
-
10.✍️ What value is given to background-color in this rule?
.note {
background-color: yellow;
color: red;
} (a) 10px (b) 8px (c) yellow (d) background-color -
11.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 16px;
}
} - 12.✍️ Which sign ends each CSS declaration? (a) : (b) . (c) ; (d) ,
- 13.🧩 Which language counts down a timer? (a) JavaScript (b) HTML (c) CSS
- 14.🌈 Which colour of light is strongest in rgb(3, 50, 196)? (a) green (b) blue (c) red
-
15.✍️ What value is given to background-color in this rule?
li {
background-color: yellow;
font-size: 20px;
} (a) yellow (b) background-color (c) 10px (d) 8px - 16.💪 Which flexbox property lines boxes up across? (a) display: flex (b) gap (c) flex-direction (d) align-items
- 17.🌈 Which hex code is bright green? (a) #00ff00 (b) #ff0000 (c) #00ffff (d) #ffff00
- 18.🖌️ Which CSS property makes the text bold? (a) color (b) font-weight (c) font-family (d) font-size
- 19.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the shorter one (c) the later one (d) neither
- 20.🌈 Which colour is rgb(0, 0, 255)? (a) cyan (b) magenta (c) blue (d) red
-
21.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 10px;
}
} (a) Yes (b) No -
22.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 18px;
}
} (a) No (b) Yes - 23.🌈 Which colour is rgb(255, 0, 0)? (a) white (b) magenta (c) red (d) cyan
- 24.✍️ How does a CSS comment start? (a) <!-- (b) # (c) // (d) /*
- 25.🎯 What kind of selector is body? (a) a class selector (b) an id selector (c) an element selector
-
26.✍️ Which property is set to 2px solid in this rule?
.box {
width: 300px;
border: 2px solid;
font-weight: bold;
} (a) font-style (b) 2px solid (c) width (d) border - 27.⚖️ Which selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
- 28.What does font-family do? (a) makes letters bigger (b) picks the font style (c) centres a heading (d) sets the letter colour
-
29.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 16px;
}
} -
30.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 32px;
}
} (a) No (b) Yes - 31.🎯 Which sign starts a class selector? (a) # (b) . (c) @ (d) &
-
32.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 210px;
justify-content: center;
}
Inside are 3 boxes, each 50px wide (no margins). - 33.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or narrower (c) turned off (d) 600px or wider
- 34.🎨 One CSS file can style how many pages? (a) many pages (b) only one word (c) only one image (d) no pages
-
35.✍️ Which property is set to 8px in this rule?
p {
padding: 8px;
margin: 10px;
} (a) border (b) 8px (c) padding (d) font-weight - 36.🎯 Which element does the selector div style? (a) <p class="star"> (b) <div class="star"> (c) <h1 id="top"> (d) <span>
- 37.🔍 Which is the odd one out? (a) makes a form box (b) puts a picture on a page (c) makes headings and lists (d) rounds box corners
-
38.🎯 Which CSS selector matches this element?
<span class="big" id="top">Hello</span> (a) #big (b) #intro (c) p (d) #top -
39.🖌️ How big is the text, in px?
h1 {
color: blue;
font-size: 12px;
text-align: left;
background-color: purple;
} -
40.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 70px;
padding: 25px;
border: 1px solid black;
margin: 15px;
}
Answer key
- centres a heading
- 76
- 30
- 3
- 272
- blue
- a class selector
- red
- an element selector
- yellow
- 20
- ;
- JavaScript
- blue
- yellow
- align-items
- #00ff00
- font-weight
- the later one
- blue
- Yes
- No
- red
- /*
- an element selector
- border
- an id selector
- picks the font style
- 16
- No
- .
- 30
- 600px or narrower
- many pages
- padding
- <div class="star">
- rounds box corners
- #top
- 12
- 122
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids