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.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 20px;
}
} - 2.What does justify-content: flex-end do? (a) packs boxes at the start (b) equal gaps, none at ends (c) puts boxes in the middle (d) packs boxes at the end
- 3.🖌️ Which CSS property colours behind the text? (a) text-align (b) color (c) font-size (d) background-color
-
4.🖌️ How big is the text, in px?
h2 {
font-size: 24px;
text-align: right;
color: yellow;
background-color: blue;
} -
5.🎯 Which CSS selector matches this element?
<p class="big" id="main">Hello</p> (a) .red (b) #logo (c) #big (d) #main -
6.✍️ What is the selector in this CSS rule?
.box {
padding: 8px;
text-align: center;
color: red;
font-weight: bold;
} (a) center (b) padding (c) .box (d) h2 - 7.🌈 In #e70000 the red part is the hex number e7. What is it as a normal number?
- 8.🎯 Which element does the selector .red style? (a) <div class="red"> (b) <div id="red"> (c) <span class="star"> (d) <div class="box">
-
9.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 18px;
}
} -
10.⚖️ What colour is the text of this element?
<p class="red" id="logo">Hi</p>
CSS:
#logo { color: orange; }
#logo { color: red; } (a) orange (b) yellow (c) blue (d) red - 11.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
-
12.✍️ What value is given to color in this rule?
body {
font-style: italic;
color: red;
width: 300px;
border: 2px solid;
} (a) 20px (b) red (c) color (d) center - 13.🌈 Which hex code is blue? (a) #ff00ff (b) #000000 (c) #0000ff (d) #00ff00
- 14.True or false: margin is space outside the border. (a) True (b) False
-
15.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 180px;
justify-content: flex-end;
}
Inside are 2 boxes, each 80px wide (no margins). -
16.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 340px;
justify-content: space-between;
}
Inside are 3 boxes, each 60px wide (no margins). -
17.✍️ Which property is set to 2px solid in this rule?
.note {
border: 2px solid;
font-weight: bold;
} (a) width (b) 2px solid (c) border (d) font-style - 18.💪 Which flexbox property lines boxes up across? (a) display: flex (b) align-items (c) justify-content (d) flex-direction
-
19.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 100px;
justify-content: space-between;
}
Inside are 2 boxes, each 40px wide (no margins). - 20.What does font-size do? (a) centres a heading (b) makes letters bigger (c) makes the text bold (d) picks the font style
-
21.🎯 Which CSS selector matches this element?
<h1 class="star" id="intro">Hello</h1> (a) #main (b) .intro (c) .menu (d) .star - 22.✍️ Which sign ends each CSS declaration? (a) : (b) , (c) . (d) ;
-
23.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 10px;
}
} - 24.Which of these does CSS do? (a) changes the page live (b) makes a form box (c) gives the page structure (d) lays out the page
- 25.🧩 Which language changes the page live? (a) HTML (b) JavaScript (c) CSS
- 26.What does justify-content: center do? (a) puts boxes in the middle (b) equal gaps, none at ends (c) packs boxes at the start (d) packs boxes at the end
- 27.🎯 Which element does the selector .menu style? (a) <li id="menu"> (b) <div class="big"> (c) <li class="menu"> (d) <li class="note">
-
28.✍️ What value is given to font-style in this rule?
.box {
font-style: italic;
color: red;
} (a) italic (b) font-style (c) red (d) 20px -
29.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-size: 20px;
text-align: center;
width: 300px;
} - 30.🎨 Which attribute adds CSS inside one tag? (a) style (b) src (c) href (d) alt
- 31.Which of these does CSS do? (a) adds space around boxes (b) reacts to a button click (c) makes a link (d) puts a picture on a page
-
32.✍️ How many declarations (property: value pairs) are in this rule?
li {
border: 2px solid;
} - 33.🎯 How many elements on a page should have the same id? (a) 5 (b) any number (c) 1 (d) 2
-
34.✍️ Which property is set to 300px in this rule?
li {
color: red;
width: 300px;
} (a) font-style (b) 300px (c) color (d) width - 35.🧩 Which language adds space around boxes? (a) CSS (b) HTML (c) JavaScript
- 36.True or false: padding is space inside the border. (a) True (b) False
-
37.🖌️ Where does the text sit on its line?
li {
color: green;
text-align: right;
font-size: 12px;
background-color: orange;
} (a) in the middle (b) on the right (c) on the left -
38.✍️ Which property is set to center in this rule?
h2 {
font-size: 20px;
margin: 10px;
text-align: center;
border: 2px solid;
} (a) center (b) margin (c) background-color (d) text-align -
39.✍️ Which property is set to 10px in this rule?
h1 {
width: 300px;
margin: 10px;
font-weight: bold;
font-size: 20px;
} (a) font-weight (b) margin (c) 10px (d) padding - 40.🌈 Which colour is rgb(255, 0, 0)? (a) bright green (b) blue (c) black (d) red
Answer key
- 16
- packs boxes at the end
- background-color
- 24
- #main
- .box
- 231
- <div class="red">
- 18
- red
- an element selector
- red
- #0000ff
- True
- 20
- 80
- border
- align-items
- 20
- makes letters bigger
- .star
- ;
- 10
- lays out the page
- JavaScript
- puts boxes in the middle
- <li class="menu">
- italic
- 3
- style
- adds space around boxes
- 1
- 1
- width
- CSS
- True
- on the right
- text-align
- margin
- red
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids