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 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 768px) {
p {
font-size: 10px;
}
} - 2.🎨 Which tag connects an outside CSS file? (a) <a> (b) <css> (c) <img> (d) <link>
-
3.✍️ Which property is set to 300px in this rule?
.note {
background-color: yellow;
font-size: 20px;
width: 300px;
} (a) font-style (b) width (c) color (d) 300px -
4.✍️ What value is given to padding in this rule?
#top {
padding: 8px;
background-color: yellow;
} (a) 2px solid (b) padding (c) 8px (d) bold -
5.✍️ What value is given to border in this rule?
h2 {
margin: 10px;
border: 2px solid;
} (a) 300px (b) border (c) 2px solid (d) italic -
6.✍️ What value is given to font-style in this rule?
li {
font-size: 20px;
text-align: center;
font-style: italic;
background-color: yellow;
} (a) 20px (b) red (c) font-style (d) italic - 7.🌈 Which colour is rgb(255, 0, 255)? (a) magenta (b) yellow (c) red (d) cyan
- 8.🌈 Which colour is #000000? (a) black (b) white (c) magenta (d) bright green
-
9.⚖️ What colour is the text of this element?
<h1 class="star" id="end">Hi</h1>
CSS:
#end { color: purple; }
#end { color: white; } (a) purple (b) red (c) white (d) black - 10.What does justify-content: space-between do? (a) packs boxes at the end (b) packs boxes at the start (c) puts boxes in the middle (d) equal gaps, none at ends
-
11.🎯 Which CSS selector matches this element?
<p class="menu" id="main">Hello</p> (a) #logo (b) .menu (c) #menu (d) .note - 12.True or false: JavaScript counts down a timer. (a) False (b) True
- 13.Which of these is margin? (a) space outside the border (b) a solid or dotted edge (c) space inside the border (d) the line round the box
- 14.True or false: .star is a class selector. (a) False (b) True
-
15.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} (a) Yes (b) No - 16.🌈 Which colour is rgb(255, 255, 0)? (a) red (b) magenta (c) yellow (d) cyan
-
17.✍️ What value is given to font-style in this rule?
h1 {
width: 300px;
color: red;
font-style: italic;
} (a) 20px (b) italic (c) font-style (d) red -
18.✍️ What value is given to font-size in this rule?
.box {
text-align: center;
font-size: 20px;
} (a) yellow (b) font-size (c) 20px (d) center -
19.⚖️ What colour is the text of this element?
<h1 class="box" id="main">Hi</h1>
CSS:
.box { color: white; }
#main { color: blue; } (a) white (b) green (c) red (d) blue - 20.🎯 Which element does the selector h1 style? (a) <div id="top"> (b) <li class="red"> (c) <h1 class="red"> (d) <h2>
-
21.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 110px;
justify-content: flex-end;
}
Inside are 2 boxes, each 50px wide (no margins). - 22.🎨 Which attribute adds CSS inside one tag? (a) src (b) style (c) href (d) alt
-
23.✍️ What value is given to border in this rule?
.box {
border: 2px solid;
background-color: yellow;
font-size: 20px;
} (a) border (b) italic (c) 2px solid (d) 300px -
24.🎯 Which CSS selector matches this element?
<div class="note" id="end">Hello</div> (a) .end (b) #hero (c) div (d) span - 25.🖌️ Which CSS property makes the text bold? (a) font-size (b) font-weight (c) background-color (d) color
-
26.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 4 boxes, each 50px wide (no margins). - 27.🎯 Which element does the selector .big style? (a) <li class="big"> (b) <div class="box"> (c) <li class="red"> (d) <li id="big">
-
28.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
border: 2px solid;
} -
29.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 100px;
justify-content: center;
}
Inside are 2 boxes, each 40px wide (no margins). - 30.✍️ Which sign goes between a property and its value? (a) - (b) ; (c) : (d) =
- 31.🌈 Which colour is #ffffff? (a) yellow (b) white (c) bright green (d) black
- 32.🌈 In #rrggbb, which colour do the last two digits give? (a) white (b) green (c) blue (d) red
-
33.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 20px;
}
} (a) Yes (b) No - 34.🎯 Which sign starts an id selector? (a) @ (b) & (c) # (d) .
-
35.🖌️ Where does the text sit on its line?
li {
color: blue;
font-size: 32px;
background-color: purple;
text-align: left;
} (a) on the right (b) on the left (c) in the middle - 36.True or false: HTML sets colours and fonts. (a) False (b) True
-
37.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 340px;
justify-content: center;
}
Inside are 4 boxes, each 50px wide (no margins). -
38.⚖️ What colour is the text of this element?
<p class="box" id="end">Hi</p>
CSS:
.box { color: black; }
p { color: purple; } (a) purple (b) white (c) blue (d) black -
39.✍️ Which property is set to 2px solid in this rule?
.box {
border: 2px solid;
font-size: 20px;
font-style: italic;
} (a) width (b) 2px solid (c) border (d) font-style - 40.True or false: padding is space inside the border. (a) False (b) True
Answer key
- 10
- <link>
- width
- 8px
- 2px solid
- italic
- magenta
- black
- white
- equal gaps, none at ends
- .menu
- True
- space outside the border
- True
- Yes
- yellow
- italic
- 20px
- blue
- <h1 class="red">
- 10
- style
- 2px solid
- div
- font-weight
- 30
- <li class="big">
- 1
- 10
- :
- white
- blue
- Yes
- #
- on the left
- False
- 70
- black
- border
- True
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids