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 padding? (a) space inside the border (b) the line round the box (c) a solid or dotted edge (d) space outside the border
- 2.What does justify-content: space-between do? (a) puts boxes in the middle (b) packs boxes at the start (c) packs boxes at the end (d) equal gaps, none at ends
- 3.🖌️ Which CSS property centres a heading? (a) color (b) font-size (c) text-align (d) font-weight
- 4.🔍 Which is the odd one out? (a) gives the page structure (b) makes a form box (c) shows a pop-up message (d) puts a picture on a page
-
5.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 1024px) {
p {
font-size: 32px;
}
} (a) No (b) Yes - 6.Which of these does JavaScript do? (a) sets colours and fonts (b) changes the page live (c) puts a picture on a page (d) adds space around boxes
-
7.✍️ How many declarations (property: value pairs) are in this rule?
li {
color: red;
font-size: 20px;
margin: 10px;
} -
8.✍️ Which property is set to italic in this rule?
body {
font-size: 20px;
color: red;
font-style: italic;
} (a) italic (b) color (c) font-size (d) font-style - 9.✍️ In color: blue; which part is the property? (a) ; (b) : (c) color (d) blue
- 10.🌈 Hex digits go 0 to 9, then A to which letter? (a) J (b) F (c) Z (d) G
-
11.✍️ Which property is set to italic in this rule?
.note {
font-style: italic;
padding: 8px;
} (a) font-size (b) color (c) italic (d) font-style -
12.✍️ Which property is set to 10px in this rule?
.box {
font-weight: bold;
margin: 10px;
text-align: center;
padding: 8px;
} (a) font-weight (b) margin (c) padding (d) 10px - 13.True or false: .big is an id selector. (a) False (b) True
-
14.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 360px;
justify-content: center;
}
Inside are 2 boxes, each 100px wide (no margins). -
15.⚖️ What colour is the text of this element?
<h1 class="menu" id="end">Hi</h1>
CSS:
#end { color: green; }
#end { color: blue; } (a) orange (b) green (c) red (d) blue -
16.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 14px;
}
} (a) No (b) Yes - 17.🌈 Which hex code is cyan? (a) #00ffff (b) #000000 (c) #ff00ff (d) #0000ff
- 18.🌈 Which colour of light is strongest in rgb(204, 89, 90)? (a) blue (b) red (c) green
-
19.🖌️ What colour are the letters?
p {
color: red;
background-color: blue;
font-size: 32px;
text-align: center;
} (a) blue (b) yellow (c) red -
20.✍️ What value is given to background-color in this rule?
h1 {
font-weight: bold;
margin: 10px;
padding: 8px;
background-color: yellow;
} (a) 10px (b) background-color (c) 8px (d) yellow -
21.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 100px;
padding: 25px;
border: 2px solid black;
margin: 20px;
} -
22.🖌️ How big is the text, in px?
h2 {
font-size: 20px;
text-align: left;
color: orange;
background-color: purple;
} - 23.💪 Which justify-content value packs boxes at the end? (a) center (b) flex-start (c) flex-end (d) space-between
-
24.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 370px;
justify-content: flex-end;
}
Inside are 4 boxes, each 80px wide (no margins). -
25.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 110px;
padding: 5px;
border: 4px solid black;
margin: 5px;
} - 26.🎨 A CSS file usually ends with which extension? (a) .js (b) .html (c) .png (d) .css
- 27.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
- 28.🧩 Which language changes the text size? (a) JavaScript (b) CSS (c) HTML
-
29.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 14px;
}
} (a) No (b) Yes -
30.✍️ Which property is set to 2px solid in this rule?
.note {
border: 2px solid;
background-color: yellow;
} (a) border (b) 2px solid (c) width (d) font-style - 31.🔍 Which is the odd one out? (a) checks a quiz answer (b) makes headings and lists (c) gives the page structure (d) makes a form box
-
32.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 22px;
}
} - 33.🌈 Which colour is rgb(255, 0, 0)? (a) white (b) magenta (c) cyan (d) red
-
34.📦 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: 15px;
border: 2px solid black;
margin: 10px;
} - 35.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
-
36.🎯 Which CSS selector matches this element?
<p class="red" id="top">Hello</p> (a) #intro (b) #red (c) #top (d) .box -
37.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 600px) {
p {
font-size: 28px;
}
} - 38.📦 In the box model, which part is the text or picture? (a) border (b) margin (c) padding (d) content
- 39.🌈 Which colour is #000000? (a) bright green (b) black (c) white (d) cyan
-
40.✍️ How many declarations (property: value pairs) are in this rule?
.box {
font-size: 20px;
}
Answer key
- space inside the border
- equal gaps, none at ends
- text-align
- shows a pop-up message
- No
- changes the page live
- 3
- font-style
- color
- F
- font-style
- margin
- False
- 80
- blue
- No
- #00ffff
- red
- red
- yellow
- 194
- 20
- flex-end
- 50
- 138
- .css
- an element selector
- CSS
- Yes
- border
- checks a quiz answer
- 22
- red
- 294
- an id selector
- #top
- 20
- content
- black
- 1
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids