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.✍️ What value is given to width in this rule?
h1 {
background-color: yellow;
color: red;
width: 300px;
} (a) 300px (b) italic (c) red (d) width -
2.⚖️ What colour is the text of this element?
<h2 class="big" id="top">Hi</h2>
CSS:
#top { color: orange; }
#top { color: purple; } (a) black (b) orange (c) purple (d) white -
3.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 50px;
padding: 10px;
border: 1px solid black;
margin: 10px;
} - 4.🔍 Which is the odd one out? (a) lays out the page (b) puts a picture on a page (c) adds space around boxes (d) changes the text size
-
5.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 14px;
}
} - 6.📱 max-width: 600px applies when the screen is ___. (a) 600px or narrower (b) 600px or wider (c) turned off (d) exactly 1000px
- 7.True or false: the content is a solid or dotted edge. (a) True (b) False
- 8.🖌️ Which CSS property sets the letter colour? (a) font-family (b) text-align (c) background-color (d) color
-
9.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
margin: 10px;
text-align: center;
padding: 8px;
background-color: yellow;
} -
10.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} - 11.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) blue (c) black (d) red
-
12.✍️ Which property is set to 300px in this rule?
h1 {
border: 2px solid;
width: 300px;
} (a) font-style (b) 300px (c) color (d) width -
13.🖌️ Where does the text sit on its line?
h2 {
color: orange;
text-align: left;
font-size: 12px;
background-color: red;
} (a) on the right (b) in the middle (c) on the left -
14.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 150px;
justify-content: space-between;
}
Inside are 2 boxes, each 40px wide (no margins). -
15.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 280px;
justify-content: space-between;
}
Inside are 4 boxes, each 40px wide (no margins). -
16.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 18px;
}
} (a) Yes (b) No -
17.⚖️ What colour is the text of this element?
<h1 class="menu" id="logo">Hi</h1>
CSS:
h1 { color: red; }
.menu { color: white; } (a) purple (b) red (c) white (d) orange - 18.🎯 What kind of selector is .star? (a) an id selector (b) an element selector (c) a class selector
- 19.📱 Responsive design means a page ___. (a) is only for laptops (b) has no pictures (c) never changes (d) fits every screen
- 20.🎨 Which attribute adds CSS inside one tag? (a) alt (b) src (c) href (d) style
- 21.🎯 What kind of selector is #end? (a) an element selector (b) an id selector (c) a class selector
-
22.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 14px;
}
} (a) No (b) Yes -
23.✍️ Which property is set to red in this rule?
h1 {
text-align: center;
color: red;
font-style: italic;
font-weight: bold;
} (a) red (b) text-align (c) font-size (d) color -
24.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} (a) Yes (b) No - 25.📦 In the box model, which part is the gap round content? (a) padding (b) border (c) margin (d) content
- 26.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
-
27.🖌️ What colour are the letters?
h1 {
color: red;
text-align: left;
font-size: 12px;
background-color: purple;
} (a) white (b) red (c) purple - 28.What does background-color do? (a) centres a heading (b) colours behind the text (c) picks the font style (d) sets the letter colour
- 29.True or false: padding is space inside the border. (a) False (b) True
- 30.🌈 Which colour is #000000? (a) blue (b) yellow (c) black (d) magenta
- 31.🎯 What kind of selector is #main? (a) an element selector (b) an id selector (c) a class selector
-
32.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 10px;
}
} - 33.✍️ Which sign goes between a property and its value? (a) = (b) - (c) : (d) ;
- 34.📦 In the box model, which part is the line round the box? (a) margin (b) content (c) padding (d) border
- 35.🔍 Which is the odd one out? (a) lays out the page (b) makes headings and lists (c) adds space around boxes (d) sets colours and fonts
- 36.True or false: HTML makes headings and lists. (a) False (b) True
-
37.✍️ What value is given to text-align in this rule?
.box {
background-color: yellow;
color: red;
text-align: center;
margin: 10px;
} (a) text-align (b) yellow (c) center (d) 10px -
38.🖌️ How big is the text, in px?
p {
font-size: 12px;
background-color: white;
text-align: right;
color: red;
} -
39.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 600px) {
p {
font-size: 20px;
}
} (a) No (b) Yes - 40.📱 What does a media query check? (a) the screen width (b) the time of day (c) the battery level (d) the page title
Answer key
- 300px
- purple
- 92
- puts a picture on a page
- 14
- 600px or narrower
- False
- color
- 4
- 18
- red
- width
- on the left
- 70
- 40
- No
- white
- a class selector
- fits every screen
- style
- an id selector
- No
- color
- Yes
- padding
- an element selector
- red
- colours behind the text
- True
- black
- an id selector
- 10
- :
- border
- makes headings and lists
- True
- center
- 12
- No
- the screen width
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids