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 selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
- 2.🖌️ Which CSS property makes letters bigger? (a) background-color (b) font-size (c) font-family (d) color
- 3.Which of these does JavaScript do? (a) puts a picture on a page (b) shows a pop-up message (c) gives the page structure (d) changes the text size
-
4.🖌️ What colour is behind the letters?
p {
font-size: 20px;
text-align: left;
background-color: green;
color: white;
} (a) yellow (b) green (c) white - 5.What does font-size do? (a) makes letters bigger (b) colours behind the text (c) centres a heading (d) makes the text bold
-
6.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 140px;
padding: 20px;
border: 1px solid black;
margin: 15px;
} -
7.🖌️ Where does the text sit on its line?
li {
color: yellow;
text-align: left;
font-size: 32px;
background-color: blue;
} (a) in the middle (b) on the left (c) on the right -
8.✍️ What value is given to font-weight in this rule?
body {
font-weight: bold;
padding: 8px;
background-color: yellow;
} (a) bold (b) font-weight (c) 300px (d) 2px solid - 9.What does justify-content: flex-end do? (a) puts boxes in the middle (b) packs boxes at the end (c) equal gaps, none at ends (d) packs boxes at the start
-
10.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: flex-end;
}
Inside are 2 boxes, each 100px wide (no margins). - 11.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) green (c) blue (d) white
-
12.⚖️ What colour is the text of this element?
<p class="big" id="end">Hi</p>
CSS:
.big { color: blue; }
.big { color: white; } (a) blue (b) white (c) black (d) yellow - 13.🌈 What is the biggest number one colour can have in rgb()? (a) 1000 (b) 255 (c) 99 (d) 100
- 14.🖌️ Which CSS property colours behind the text? (a) background-color (b) font-size (c) color (d) font-family
- 15.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or narrower (c) 600px or wider (d) turned off
- 16.🌈 Which hex code is yellow? (a) #00ffff (b) #ffff00 (c) #ff0000 (d) #000000
-
17.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
color: red;
width: 300px;
} - 18.True or false: HTML puts a picture on a page. (a) False (b) True
-
19.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 768px) {
p {
font-size: 32px;
}
} -
20.🖌️ Where does the text sit on its line?
h1 {
background-color: red;
color: blue;
text-align: left;
font-size: 16px;
} (a) on the right (b) in the middle (c) on the left - 21.✍️ Which sign ends each CSS declaration? (a) . (b) : (c) , (d) ;
- 22.True or false: padding is space inside the border. (a) True (b) False
- 23.📱 What does a media query check? (a) the time of day (b) the page title (c) the screen width (d) the battery level
- 24.🌈 Which colour is #ff00ff? (a) black (b) magenta (c) blue (d) red
- 25.🧩 Which language shows a pop-up message? (a) HTML (b) CSS (c) JavaScript
- 26.🌈 In #00af00 the green part is the hex number af. What is it as a normal number?
- 27.✍️ How does a CSS comment start? (a) <!-- (b) /* (c) // (d) #
-
28.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 16px;
}
} - 29.🎯 Which element does the selector li style? (a) <span class="big"> (b) <p id="hero"> (c) <div> (d) <li class="big">
-
30.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 50px;
padding: 15px;
border: 5px solid black;
margin: 5px;
} - 31.💪 Which flexbox property sets space between boxes? (a) align-items (b) display: flex (c) gap (d) flex-direction
-
32.✍️ What is the selector in this CSS rule?
body {
text-align: center;
border: 2px solid;
font-size: 20px;
} (a) 2px solid (b) .box (c) body (d) text-align -
33.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 14px;
}
} (a) Yes (b) No - 34.🧩 Which language reacts to a button click? (a) HTML (b) CSS (c) JavaScript
-
35.🎯 Which CSS selector matches this element?
<h1 class="note" id="logo">Hello</h1> (a) #end (b) .big (c) #note (d) .note - 36.📱 min-width: 800px applies when the screen is ___. (a) exactly 100px (b) turned off (c) 800px or narrower (d) 800px or wider
-
37.✍️ What is the selector in this CSS rule?
h2 {
font-style: italic;
text-align: center;
padding: 8px;
font-size: 20px;
} (a) center (b) h1 (c) h2 (d) font-style -
38.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 340px;
justify-content: center;
}
Inside are 4 boxes, each 60px wide (no margins). - 39.📦 In the box model, which part is the gap to other boxes? (a) padding (b) border (c) margin (d) content
- 40.True or false: JavaScript reacts to a button click. (a) True (b) False
Answer key
- an id selector
- font-size
- shows a pop-up message
- green
- makes letters bigger
- 212
- on the left
- bold
- packs boxes at the end
- 60
- blue
- white
- 255
- background-color
- 600px or narrower
- #ffff00
- 2
- True
- 32
- on the left
- ;
- True
- the screen width
- magenta
- JavaScript
- 175
- /*
- 20
- <li class="big">
- 100
- gap
- body
- No
- JavaScript
- .note
- 800px or wider
- h2
- 50
- margin
- True
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids