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?
p {
font-size: 28px;
background-color: red;
color: black;
text-align: left;
} (a) on the right (b) on the left (c) in the middle -
2.✍️ How many declarations (property: value pairs) are in this rule?
.note {
text-align: center;
color: red;
border: 2px solid;
font-weight: bold;
} -
3.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 140px;
justify-content: flex-end;
}
Inside are 2 boxes, each 60px wide (no margins). -
4.✍️ How many declarations (property: value pairs) are in this rule?
body {
padding: 8px;
} -
5.🎯 Which CSS selector matches this element?
<p class="menu" id="top">Hello</p> (a) #intro (b) h1 (c) #menu (d) #top -
6.✍️ Which property is set to red in this rule?
li {
color: red;
width: 300px;
} (a) text-align (b) red (c) color (d) font-size - 7.🌈 Which colour is #000000? (a) black (b) red (c) cyan (d) yellow
- 8.📦 In the box model, which part is the line round the box? (a) border (b) content (c) margin (d) padding
- 9.💪 Which justify-content value packs boxes at the end? (a) space-between (b) flex-end (c) center (d) flex-start
-
10.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 410px;
justify-content: space-between;
}
Inside are 4 boxes, each 80px wide (no margins). -
11.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 14px;
}
} (a) No (b) Yes -
12.🖌️ What colour are the letters?
h1 {
background-color: yellow;
font-size: 28px;
text-align: left;
color: blue;
} (a) yellow (b) blue (c) black -
13.🖌️ What colour is behind the letters?
li {
background-color: white;
font-size: 28px;
color: purple;
text-align: right;
} (a) white (b) green (c) purple - 14.Which of these is padding? (a) a solid or dotted edge (b) space inside the border (c) space outside the border (d) the text or picture
- 15.🧩 Which language makes headings and lists? (a) CSS (b) HTML (c) JavaScript
- 16.🎯 What kind of selector is .menu? (a) an id selector (b) a class selector (c) an element selector
-
17.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 768px) {
p {
font-size: 32px;
}
} - 18.True or false: #main is a class selector. (a) True (b) False
- 19.🎨 Which attribute adds CSS inside one tag? (a) src (b) href (c) alt (d) style
-
20.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 490px;
justify-content: space-between;
}
Inside are 4 boxes, each 100px wide (no margins). -
21.⚖️ What colour is the text of this element?
<h2 class="red" id="intro">Hi</h2>
CSS:
h2 { color: green; }
h2 { color: blue; } (a) white (b) blue (c) green (d) orange - 22.What does text-align do? (a) makes letters bigger (b) sets the letter colour (c) centres a heading (d) makes the text bold
-
23.🎯 Which CSS selector matches this element?
<li class="big" id="main">Hello</li> (a) #logo (b) li (c) .main (d) .red - 24.🔍 Which is the odd one out? (a) rounds box corners (b) makes a form box (c) makes headings and lists (d) makes a link
-
25.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 110px;
padding: 25px;
border: 5px solid black;
margin: 5px;
} - 26.True or false: margin is the gap round content. (a) True (b) False
-
27.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 170px;
justify-content: flex-end;
}
Inside are 2 boxes, each 80px wide (no margins). -
28.✍️ What is the selector in this CSS rule?
#top {
text-align: center;
margin: 10px;
color: red;
} (a) #top (b) li (c) 10px (d) text-align - 29.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) turned off (c) 800px or wider (d) exactly 100px
- 30.📱 What does a media query check? (a) the time of day (b) the screen width (c) the battery level (d) the page title
-
31.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 768px) {
p {
font-size: 32px;
}
} (a) No (b) Yes -
32.✍️ What value is given to color in this rule?
p {
text-align: center;
color: red;
} (a) color (b) 20px (c) red (d) center - 33.What does font-family do? (a) colours behind the text (b) picks the font style (c) makes letters bigger (d) sets the letter colour
- 34.🎯 What kind of selector is .card? (a) an element selector (b) a class selector (c) an id selector
- 35.True or false: HTML reacts to a button click. (a) True (b) False
- 36.✍️ Which sign goes between a property and its value? (a) ; (b) - (c) : (d) =
- 37.🎯 Which element does the selector .star style? (a) <li id="star"> (b) <div class="note"> (c) <li class="star"> (d) <li class="menu">
- 38.What does font-size do? (a) colours behind the text (b) makes letters bigger (c) makes the text bold (d) sets the letter colour
- 39.True or false: #logo is an id selector. (a) False (b) True
-
40.✍️ Which property is set to red in this rule?
h1 {
color: red;
background-color: yellow;
} (a) red (b) text-align (c) color (d) font-size
Answer key
- on the left
- 4
- 20
- 1
- #top
- color
- black
- border
- flex-end
- 30
- Yes
- blue
- white
- space inside the border
- HTML
- a class selector
- 32
- False
- style
- 30
- blue
- centres a heading
- li
- rounds box corners
- 180
- False
- 10
- #top
- 800px or wider
- the screen width
- Yes
- red
- picks the font style
- a class selector
- False
- :
- <li class="star">
- makes letters bigger
- True
- color
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids