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 is the odd one out? (a) adds space around boxes (b) lays out the page (c) reacts to a button click (d) rounds box corners
-
2.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 600px) {
p {
font-size: 24px;
}
} -
3.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 260px;
padding: 5px;
border: 2px solid black;
margin: 10px;
} -
4.✍️ What is the selector in this CSS rule?
h1 {
border: 2px solid;
padding: 8px;
font-size: 20px;
text-align: center;
} (a) h1 (b) p (c) border (d) 8px -
5.🖌️ What colour is behind the letters?
li {
background-color: white;
text-align: right;
font-size: 16px;
color: black;
} (a) red (b) white (c) black - 6.True or false: #hero is an id selector. (a) False (b) True
- 7.🌈 In #00005e the blue part is the hex number 5e. What is it as a normal number?
-
8.⚖️ What colour is the text of this element?
<h1 class="note" id="logo">Hi</h1>
CSS:
.note { color: orange; }
.note { color: red; } (a) red (b) orange (c) yellow (d) white -
9.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 190px;
justify-content: space-between;
}
Inside are 2 boxes, each 80px wide (no margins). - 10.True or false: JavaScript reacts to a button click. (a) False (b) True
- 11.🌈 What is the biggest number one colour can have in rgb()? (a) 99 (b) 1000 (c) 100 (d) 255
-
12.⚖️ What colour is the text of this element?
<h1 class="star" id="main">Hi</h1>
CSS:
.star { color: blue; }
.star { color: purple; } (a) black (b) purple (c) white (d) blue - 13.Which of these is margin? (a) a solid or dotted edge (b) the line round the box (c) the gap to other boxes (d) space inside the border
- 14.🔍 Which is the odd one out? (a) makes a link (b) makes a form box (c) lays out the page (d) puts a picture on a page
-
15.✍️ How many declarations (property: value pairs) are in this rule?
p {
border: 2px solid;
font-style: italic;
padding: 8px;
color: red;
} - 16.What does background-color do? (a) makes the text bold (b) colours behind the text (c) makes letters bigger (d) centres a heading
- 17.What does justify-content: flex-start 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
- 18.True or false: margin is the gap round content. (a) False (b) True
-
19.✍️ What value is given to border in this rule?
#top {
border: 2px solid;
padding: 8px;
} (a) italic (b) border (c) 300px (d) 2px solid - 20.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
-
21.✍️ Which property is set to 2px solid in this rule?
#top {
width: 300px;
border: 2px solid;
} (a) 2px solid (b) width (c) border (d) font-style -
22.⚖️ What colour is the text of this element?
<h2 class="box" id="main">Hi</h2>
CSS:
#main { color: white; }
#main { color: purple; } (a) black (b) white (c) purple (d) orange - 23.🌈 In #002400 the green part is the hex number 24. What is it as a normal number?
- 24.True or false: padding is space inside the border. (a) False (b) True
-
25.✍️ How many declarations (property: value pairs) are in this rule?
.box {
text-align: center;
color: red;
font-weight: bold;
} - 26.🔍 Which is the odd one out? (a) gives the page structure (b) makes headings and lists (c) makes a link (d) shows a pop-up message
- 27.📱 Responsive design means a page ___. (a) is only for laptops (b) has no pictures (c) fits every screen (d) never changes
-
28.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 120px;
justify-content: space-between;
}
Inside are 2 boxes, each 40px wide (no margins). - 29.True or false: HTML rounds box corners. (a) False (b) True
-
30.🖌️ How big is the text, in px?
h2 {
background-color: blue;
text-align: left;
font-size: 28px;
color: yellow;
} -
31.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 768px) {
p {
font-size: 12px;
}
} - 32.True or false: padding is a solid or dotted edge. (a) False (b) True
-
33.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
background-color: yellow;
font-size: 20px;
width: 300px;
color: red;
} - 34.📦 In the box model, which part is the gap to other boxes? (a) margin (b) content (c) border (d) padding
- 35.💪 Which justify-content value packs boxes at the start? (a) flex-start (b) center (c) space-between (d) flex-end
-
36.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 50px;
padding: 5px;
border: 2px solid black;
margin: 0px;
} -
37.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 210px;
justify-content: space-between;
}
Inside are 2 boxes, each 100px wide (no margins). -
38.🖌️ Where does the text sit on its line?
p {
font-size: 24px;
text-align: left;
color: red;
background-color: purple;
} (a) on the left (b) on the right (c) in the middle -
39.🖌️ What colour is behind the letters?
li {
font-size: 20px;
text-align: right;
background-color: white;
color: blue;
} (a) black (b) white (c) blue - 40.🔍 Which is the odd one out? (a) lays out the page (b) adds space around boxes (c) rounds box corners (d) checks a quiz answer
Answer key
- reacts to a button click
- 24
- 294
- h1
- white
- True
- 94
- red
- 30
- True
- 255
- purple
- the gap to other boxes
- lays out the page
- 4
- colours behind the text
- packs boxes at the start
- False
- 2px solid
- an id selector
- border
- purple
- 36
- True
- 3
- shows a pop-up message
- fits every screen
- 40
- False
- 28
- 12
- False
- 4
- margin
- flex-start
- 64
- 10
- on the left
- white
- checks a quiz answer
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids