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.📦 In the box model, which part is space inside the border? (a) content (b) border (c) margin (d) padding
- 2.True or false: margin is space outside the border. (a) True (b) False
-
3.✍️ How many declarations (property: value pairs) are in this rule?
#top {
margin: 10px;
} -
4.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 600px) {
p {
font-size: 22px;
}
} (a) Yes (b) No - 5.📱 What does a media query check? (a) the time of day (b) the screen width (c) the battery level (d) the page title
-
6.🖌️ Where does the text sit on its line?
h1 {
background-color: blue;
color: white;
font-size: 24px;
text-align: right;
} (a) on the left (b) on the right (c) in the middle -
7.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
font-style: italic;
font-weight: bold;
text-align: center;
margin: 10px;
} - 8.What does background-color do? (a) centres a heading (b) colours behind the text (c) makes the text bold (d) sets the letter colour
- 9.True or false: .card is a class selector. (a) True (b) False
- 10.✍️ In color: blue; which part is the value? (a) color (b) blue (c) : (d) ;
- 11.🌈 Which colour is #00ffff? (a) white (b) cyan (c) magenta (d) yellow
-
12.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 70px;
padding: 5px;
border: 2px solid black;
margin: 0px;
} - 13.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the shorter one (c) the first one (d) neither
-
14.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 130px;
padding: 30px;
border: 4px solid black;
margin: 10px;
} -
15.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 22px;
}
} -
16.🎯 Which CSS selector matches this element?
<span class="red" id="main">Hello</span> (a) #logo (b) .main (c) p (d) span -
17.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 190px;
padding: 5px;
border: 1px solid black;
margin: 0px;
} - 18.🎯 Which sign starts a class selector? (a) & (b) . (c) # (d) @
- 19.🌈 Which colour is rgb(255, 0, 0)? (a) cyan (b) red (c) white (d) magenta
-
20.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 16px;
}
} - 21.True or false: .menu is an id selector. (a) False (b) True
-
22.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 280px;
justify-content: center;
}
Inside are 4 boxes, each 50px wide (no margins). - 23.True or false: CSS adds space around boxes. (a) True (b) False
- 24.🎯 Which element does the selector p style? (a) <h2 class="note"> (b) <h1> (c) <li id="intro"> (d) <p class="note">
-
25.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
font-weight: bold;
font-size: 20px;
margin: 10px;
padding: 8px;
} -
26.✍️ Which property is set to bold in this rule?
body {
color: red;
border: 2px solid;
padding: 8px;
font-weight: bold;
} (a) width (b) bold (c) font-weight (d) border - 27.What does color do? (a) colours behind the text (b) centres a heading (c) makes letters bigger (d) sets the letter colour
- 28.✍️ How does a CSS comment start? (a) /* (b) # (c) // (d) <!--
-
29.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 340px;
justify-content: flex-end;
}
Inside are 4 boxes, each 80px wide (no margins). - 30.🎯 Which element does the selector .big style? (a) <span class="box"> (b) <div class="big"> (c) <div class="red"> (d) <div id="big">
-
31.🖌️ What colour are the letters?
h1 {
text-align: right;
background-color: black;
font-size: 40px;
color: blue;
} (a) yellow (b) blue (c) black - 32.🌈 Which hex code is red? (a) #00ffff (b) #ffff00 (c) #ffffff (d) #ff0000
- 33.🌈 Which colour is #000000? (a) white (b) yellow (c) blue (d) black
-
34.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
padding: 8px;
} -
35.🎯 Which CSS selector matches this element?
<li class="star" id="logo">Hello</li> (a) div (b) #star (c) li (d) #end - 36.True or false: #hero is a class selector. (a) False (b) True
- 37.True or false: CSS rounds box corners. (a) False (b) True
-
38.🎯 Which CSS selector matches this element?
<p class="note" id="top">Hello</p> (a) .big (b) #note (c) .note (d) #intro - 39.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
- 40.🖌️ Which CSS property colours behind the text? (a) font-size (b) font-family (c) background-color (d) color
Answer key
- padding
- True
- 1
- Yes
- the screen width
- on the right
- 4
- colours behind the text
- True
- blue
- cyan
- 84
- the later one
- 218
- 22
- span
- 202
- .
- red
- 16
- False
- 40
- True
- <p class="note">
- 4
- font-weight
- sets the letter colour
- /*
- 20
- <div class="big">
- blue
- #ff0000
- black
- 1
- li
- False
- True
- .note
- an element selector
- background-color
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids