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 of these is margin? (a) space inside the border (b) the text or picture (c) a solid or dotted edge (d) space outside the border
- 2.🌈 Which colour is #ffff00? (a) yellow (b) magenta (c) blue (d) bright green
- 3.What does color do? (a) sets the letter colour (b) colours behind the text (c) makes the text bold (d) centres a heading
-
4.✍️ Which property is set to 8px in this rule?
body {
font-style: italic;
margin: 10px;
padding: 8px;
} (a) 8px (b) font-weight (c) padding (d) border -
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: 270px;
padding: 10px;
border: 5px solid black;
margin: 10px;
} - 6.✍️ In color: blue; which part is the property? (a) : (b) blue (c) color (d) ;
- 7.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) exactly 1000px (c) 600px or narrower (d) 600px or wider
-
8.🎯 Which CSS selector matches this element?
<h2 class="star" id="logo">Hello</h2> (a) .menu (b) #end (c) .logo (d) #logo -
9.✍️ What is the selector in this CSS rule?
li {
text-align: center;
padding: 8px;
background-color: yellow;
width: 300px;
} (a) li (b) 8px (c) body (d) text-align -
10.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 300px;
padding: 25px;
border: 4px solid black;
margin: 0px;
} - 11.🖌️ Which CSS property colours behind the text? (a) font-size (b) font-weight (c) text-align (d) background-color
-
12.✍️ How many declarations (property: value pairs) are in this rule?
p {
background-color: yellow;
border: 2px solid;
text-align: center;
font-size: 20px;
} - 13.📦 In the box model, which part is the gap round content? (a) margin (b) border (c) content (d) padding
- 14.🖌️ Which CSS property picks the font style? (a) font-family (b) background-color (c) font-size (d) font-weight
- 15.📦 In the box model, which part is space outside the border? (a) margin (b) content (c) border (d) padding
-
16.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 90px;
padding: 30px;
border: 2px solid black;
margin: 20px;
} - 17.🌈 In #0000ee the blue part is the hex number ee. What is it as a normal number?
-
18.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 200px;
justify-content: flex-end;
}
Inside are 4 boxes, each 40px wide (no margins). - 19.💪 Which flexbox property sets space between boxes? (a) justify-content (b) display: flex (c) gap (d) flex-direction
-
20.⚖️ What colour is the text of this element?
<p class="menu" id="end">Hi</p>
CSS:
.menu { color: black; }
#end { color: blue; }
p { color: purple; } (a) blue (b) black (c) red (d) purple -
21.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 22px;
}
} (a) No (b) Yes - 22.🎯 How many elements on a page should have the same id? (a) 1 (b) 5 (c) 2 (d) any number
-
23.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 480px) {
p {
font-size: 10px;
}
} (a) Yes (b) No -
24.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 8px;
}
} -
25.🖌️ What colour is behind the letters?
h2 {
font-size: 20px;
background-color: green;
text-align: right;
color: white;
} (a) green (b) orange (c) white -
26.📦 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: 20px;
border: 5px solid black;
margin: 10px;
} - 27.True or false: padding is space outside the border. (a) True (b) False
- 28.🖌️ Which CSS property makes letters bigger? (a) background-color (b) text-align (c) font-family (d) font-size
- 29.🔍 Which is the odd one out? (a) rounds box corners (b) counts down a timer (c) lays out the page (d) sets colours and fonts
-
30.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 16px;
}
} (a) Yes (b) No - 31.🌈 Which colour is #000000? (a) blue (b) bright green (c) red (d) black
-
32.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 160px;
justify-content: space-between;
}
Inside are 2 boxes, each 40px wide (no margins). - 33.🧩 Which language puts a picture on a page? (a) CSS (b) JavaScript (c) HTML
- 34.True or false: the border is the text or picture. (a) False (b) True
- 35.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
- 36.🎨 What does CSS stand for? (a) Computer Style Sheets (b) Creative Sheet System (c) Cascading Style Sheets (d) Colourful Site Styles
- 37.🎯 Which element does the selector .box style? (a) <h1 class="menu"> (b) <p class="star"> (c) <p id="box"> (d) <p class="box">
- 38.🧩 Which language makes headings and lists? (a) HTML (b) JavaScript (c) CSS
-
39.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 330px;
justify-content: flex-start;
}
Inside are 4 boxes, each 80px wide (no margins). -
40.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 180px;
padding: 30px;
border: 1px solid black;
margin: 15px;
}
Answer key
- space outside the border
- yellow
- sets the letter colour
- padding
- 300
- color
- 600px or narrower
- #logo
- li
- 358
- background-color
- 4
- padding
- font-family
- margin
- 194
- 238
- 40
- gap
- blue
- No
- 1
- Yes
- 8
- green
- 210
- False
- font-size
- counts down a timer
- No
- black
- 80
- HTML
- False
- an element selector
- Cascading Style Sheets
- <p class="box">
- HTML
- 10
- 272
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids