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 tag helps phones show a page at the right size? (a) the br tag (b) the hr tag (c) the title tag (d) the viewport meta tag
- 2.🎨 Which attribute adds CSS inside one tag? (a) src (b) href (c) alt (d) style
- 3.🌈 Which hex code is red? (a) #00ff00 (b) #0000ff (c) #ff00ff (d) #ff0000
-
4.✍️ What value is given to font-weight in this rule?
#top {
width: 300px;
font-weight: bold;
background-color: yellow;
} (a) font-weight (b) 300px (c) 2px solid (d) bold - 5.🌈 In #0000fd the blue part is the hex number fd. What is it as a normal number?
-
6.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 28px;
}
} -
7.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 12px;
}
} (a) Yes (b) No - 8.🌈 Which colour is rgb(255, 0, 0)? (a) red (b) cyan (c) black (d) white
-
9.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 20px;
}
} (a) No (b) Yes -
10.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 240px;
justify-content: space-between;
}
Inside are 3 boxes, each 40px wide (no margins). -
11.⚖️ What colour is the text of this element?
<p class="big" id="top">Hi</p>
CSS:
p { color: black; }
p { color: yellow; } (a) blue (b) white (c) black (d) yellow -
12.✍️ How many declarations (property: value pairs) are in this rule?
li {
text-align: center;
border: 2px solid;
} -
13.⚖️ What colour is the text of this element?
<p class="red" id="top">Hi</p>
CSS:
.red { color: orange; }
.red { color: yellow; } (a) yellow (b) blue (c) purple (d) orange - 14.🖌️ Which CSS property sets the letter colour? (a) text-align (b) background-color (c) color (d) font-weight
- 15.💪 Which flexbox property lines boxes up across? (a) display: flex (b) gap (c) flex-direction (d) align-items
- 16.True or false: .star is a class selector. (a) True (b) False
-
17.✍️ What value is given to border in this rule?
h2 {
border: 2px solid;
background-color: yellow;
} (a) 300px (b) border (c) italic (d) 2px solid -
18.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 180px;
justify-content: flex-start;
}
Inside are 2 boxes, each 60px wide (no margins). -
19.✍️ Which property is set to 2px solid in this rule?
h1 {
border: 2px solid;
width: 300px;
margin: 10px;
} (a) width (b) font-style (c) border (d) 2px solid - 20.What does justify-content: flex-start do? (a) packs boxes at the start (b) equal gaps, none at ends (c) packs boxes at the end (d) puts boxes in the middle
-
21.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 220px;
justify-content: flex-start;
}
Inside are 3 boxes, each 60px wide (no margins). -
22.🖌️ What colour is behind the letters?
h1 {
text-align: left;
background-color: red;
font-size: 28px;
color: blue;
} (a) yellow (b) red (c) blue - 23.📦 In the box model, which part is space inside the border? (a) border (b) padding (c) content (d) margin
- 24.🧩 Which language adds space around boxes? (a) CSS (b) HTML (c) JavaScript
- 25.What does justify-content: space-between do? (a) packs boxes at the end (b) equal gaps, none at ends (c) puts boxes in the middle (d) packs boxes at the start
-
26.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 480px) {
p {
font-size: 14px;
}
} (a) Yes (b) No -
27.✍️ What is the selector in this CSS rule?
p {
padding: 8px;
font-size: 20px;
border: 2px solid;
font-style: italic;
} (a) padding (b) 20px (c) .note (d) p -
28.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
text-align: center;
font-weight: bold;
border: 2px solid;
background-color: yellow;
} - 29.True or false: margin is space outside the border. (a) False (b) True
- 30.📦 In the box model, which part is space outside the border? (a) padding (b) border (c) content (d) margin
-
31.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 220px;
padding: 10px;
border: 1px solid black;
margin: 15px;
} - 32.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) align-items (c) display: flex (d) gap
-
33.✍️ What is the selector in this CSS rule?
.note {
font-size: 20px;
text-align: center;
width: 300px;
padding: 8px;
} (a) font-size (b) center (c) #top (d) .note -
34.🖌️ What colour are the letters?
h1 {
background-color: green;
color: orange;
font-size: 32px;
text-align: right;
} (a) green (b) blue (c) orange -
35.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 12px;
}
} - 36.🧩 Which language shows a pop-up message? (a) JavaScript (b) HTML (c) CSS
- 37.True or false: the content is the text or picture. (a) True (b) False
- 38.📱 What does a media query check? (a) the screen width (b) the page title (c) the battery level (d) the time of day
-
39.⚖️ What colour is the text of this element?
<h1 class="box" id="main">Hi</h1>
CSS:
h1 { color: black; }
h1 { color: blue; } (a) black (b) orange (c) red (d) blue -
40.⚖️ What colour is the text of this element?
<h1 class="note" id="top">Hi</h1>
CSS:
#top { color: blue; }
#top { color: white; } (a) blue (b) black (c) white (d) red
Answer key
- the viewport meta tag
- style
- #ff0000
- bold
- 253
- 20
- Yes
- red
- Yes
- 60
- yellow
- 2
- yellow
- color
- align-items
- True
- 2px solid
- 60
- border
- packs boxes at the start
- 40
- red
- padding
- CSS
- equal gaps, none at ends
- Yes
- p
- 4
- True
- margin
- 272
- display: flex
- .note
- orange
- 16
- JavaScript
- True
- the screen width
- blue
- white
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids