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.🖌️ Where does the text sit on its line?
li {
font-size: 28px;
text-align: right;
background-color: blue;
color: black;
} (a) on the right (b) in the middle (c) on the left -
2.🖌️ What colour is behind the letters?
h2 {
background-color: orange;
font-size: 32px;
color: white;
text-align: left;
} (a) red (b) orange (c) white - 3.🎯 Which element does the selector p style? (a) <p class="big"> (b) <li id="main"> (c) <h2 class="big"> (d) <h1>
-
4.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 70px;
padding: 20px;
border: 5px solid black;
margin: 10px;
} -
5.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 18px;
}
} (a) Yes (b) No -
6.⚖️ What colour is the text of this element?
<p class="big" id="top">Hi</p>
CSS:
#top { color: yellow; }
#top { color: red; } (a) white (b) yellow (c) red (d) blue - 7.True or false: JavaScript changes the page live. (a) False (b) True
- 8.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
- 9.🎯 How many elements on a page should have the same id? (a) 1 (b) 5 (c) 2 (d) any number
- 10.✍️ Which sign goes between a property and its value? (a) - (b) ; (c) = (d) :
- 11.🎯 What kind of selector is #hero? (a) a class selector (b) an element selector (c) an id selector
- 12.🌈 In #004100 the green part is the hex number 41. What is it as a normal number?
- 13.🖌️ Which CSS property makes letters bigger? (a) font-size (b) font-weight (c) color (d) background-color
-
14.✍️ Which property is set to yellow in this rule?
body {
margin: 10px;
background-color: yellow;
} (a) padding (b) margin (c) yellow (d) background-color - 15.True or false: HTML lays out the page. (a) True (b) False
-
16.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 230px;
padding: 5px;
border: 5px solid black;
margin: 5px;
} -
17.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 220px;
padding: 10px;
border: 2px solid black;
margin: 20px;
} -
18.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 270px;
justify-content: flex-end;
}
Inside are 4 boxes, each 50px wide (no margins). - 19.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
-
20.⚖️ What colour is the text of this element?
<p class="big" id="end">Hi</p>
CSS:
p { color: yellow; }
.big { color: blue; } (a) purple (b) yellow (c) blue (d) red - 21.🎯 What kind of selector is #main? (a) an id selector (b) a class selector (c) an element selector
- 22.🌈 In #rrggbb, which colour do the first two digits give? (a) red (b) blue (c) green (d) black
-
23.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 18px;
}
} -
24.✍️ How many declarations (property: value pairs) are in this rule?
.box {
font-weight: bold;
background-color: yellow;
} - 25.🌈 Which colour of light is strongest in rgb(152, 37, 13)? (a) green (b) red (c) blue
- 26.📱 min-width: 800px applies when the screen is ___. (a) exactly 100px (b) turned off (c) 800px or narrower (d) 800px or wider
-
27.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 26px;
}
} (a) No (b) Yes -
28.💪 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). - 29.True or false: CSS reacts to a button click. (a) True (b) False
-
30.🎯 Which CSS selector matches this element?
<h1 class="note" id="logo">Hello</h1> (a) h2 (b) h1 (c) #end (d) #note - 31.🖌️ Which CSS property picks the font style? (a) color (b) font-family (c) text-align (d) background-color
- 32.What does background-color do? (a) makes the text bold (b) colours behind the text (c) sets the letter colour (d) picks the font style
- 33.True or false: CSS adds space around boxes. (a) False (b) True
- 34.📱 What does a media query check? (a) the time of day (b) the battery level (c) the page title (d) the screen width
-
35.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 220px;
justify-content: flex-start;
}
Inside are 4 boxes, each 50px wide (no margins). - 36.True or false: .menu is an id selector. (a) True (b) False
-
37.⚖️ What colour is the text of this element?
<h2 class="note" id="top">Hi</h2>
CSS:
.note { color: purple; }
.note { color: blue; } (a) black (b) purple (c) orange (d) blue - 38.🌈 In #00dc00 the green part is the hex number dc. What is it as a normal number?
-
39.✍️ What value is given to font-weight in this rule?
h1 {
border: 2px solid;
font-weight: bold;
font-style: italic;
} (a) bold (b) font-weight (c) 300px (d) 2px solid - 40.🌈 Which colour is rgb(255, 255, 255)? (a) magenta (b) bright green (c) cyan (d) white
Answer key
- on the right
- orange
- <p class="big">
- 140
- No
- red
- True
- an element selector
- 1
- :
- an id selector
- 65
- font-size
- background-color
- False
- 260
- 284
- 70
- an id selector
- blue
- an id selector
- red
- 24
- 2
- red
- 800px or wider
- Yes
- 10
- False
- h1
- font-family
- colours behind the text
- True
- the screen width
- 20
- False
- blue
- 220
- bold
- white
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids