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.🎯 Which sign starts an id selector? (a) . (b) & (c) # (d) @
- 2.📦 In the box model, which part is space outside the border? (a) border (b) content (c) padding (d) margin
-
3.⚖️ What colour is the text of this element?
<p class="menu" id="intro">Hi</p>
CSS:
p { color: green; }
#intro { color: white; } (a) orange (b) white (c) black (d) green -
4.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 290px;
padding: 25px;
border: 5px solid black;
margin: 20px;
} - 5.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
- 6.🎯 What kind of selector is .card? (a) a class selector (b) an id selector (c) an element selector
-
7.⚖️ What colour is the text of this element?
<p class="note" id="intro">Hi</p>
CSS:
#intro { color: yellow; }
.note { color: red; }
p { color: white; } (a) white (b) red (c) black (d) yellow - 8.What does justify-content: flex-end do? (a) packs boxes at the start (b) packs boxes at the end (c) puts boxes in the middle (d) equal gaps, none at ends
-
9.⚖️ What colour is the text of this element?
<h1 class="red" id="main">Hi</h1>
CSS:
.red { color: green; }
.red { color: red; } (a) blue (b) white (c) green (d) red -
10.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 210px;
justify-content: flex-start;
}
Inside are 2 boxes, each 100px wide (no margins). - 11.What does font-family do? (a) makes the text bold (b) colours behind the text (c) picks the font style (d) sets the letter colour
-
12.🖌️ What colour are the letters?
h2 {
text-align: center;
color: orange;
background-color: green;
font-size: 16px;
} (a) green (b) orange (c) yellow - 13.True or false: .star is a class selector. (a) False (b) True
- 14.🎯 Which element does the selector #end style? (a) <p class="end"> (b) <p id="end"> (c) <p id="hero"> (d) <h1 class="big">
-
15.✍️ What value is given to margin in this rule?
#top {
margin: 10px;
font-size: 20px;
font-style: italic;
border: 2px solid;
} (a) margin (b) 8px (c) bold (d) 10px - 16.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) exactly 1000px (c) turned off (d) 600px or narrower
- 17.True or false: CSS counts down a timer. (a) False (b) True
- 18.Which of these does CSS do? (a) makes headings and lists (b) reacts to a button click (c) makes a form box (d) rounds box corners
- 19.🔍 Which is the odd one out? (a) makes a link (b) makes headings and lists (c) sets colours and fonts (d) makes a form box
- 20.📱 Responsive design means a page ___. (a) has no pictures (b) fits every screen (c) never changes (d) is only for laptops
- 21.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) blue (c) black (d) red
-
22.✍️ What is the selector in this CSS rule?
li {
color: red;
background-color: yellow;
margin: 10px;
} (a) body (b) yellow (c) li (d) color - 23.🖌️ Which CSS property centres a heading? (a) color (b) text-align (c) font-family (d) font-weight
-
24.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} (a) Yes (b) No - 25.🌈 What is the biggest number one colour can have in rgb()? (a) 100 (b) 99 (c) 1000 (d) 255
-
26.✍️ Which property is set to italic in this rule?
li {
background-color: yellow;
font-style: italic;
text-align: center;
} (a) font-style (b) color (c) font-size (d) italic -
27.⚖️ What colour is the text of this element?
<h2 class="star" id="top">Hi</h2>
CSS:
.star { color: red; }
.star { color: blue; } (a) yellow (b) green (c) blue (d) red -
28.⚖️ What colour is the text of this element?
<h1 class="menu" id="top">Hi</h1>
CSS:
#top { color: orange; }
#top { color: purple; } (a) blue (b) orange (c) yellow (d) purple - 29.🌈 Hex digits go 0 to 9, then A to which letter? (a) G (b) Z (c) F (d) J
-
30.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 320px;
justify-content: flex-start;
}
Inside are 3 boxes, each 100px wide (no margins). - 31.💪 Which justify-content value packs boxes at the start? (a) center (b) space-between (c) flex-start (d) flex-end
- 32.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) white (c) green (d) blue
- 33.🎯 What kind of selector is .menu? (a) an element selector (b) an id selector (c) a class selector
- 34.🎯 Which sign starts a class selector? (a) . (b) @ (c) & (d) #
-
35.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
color: red;
font-size: 20px;
} -
36.✍️ What value is given to background-color in this rule?
h2 {
color: red;
background-color: yellow;
} (a) 10px (b) background-color (c) yellow (d) 8px -
37.🖌️ What colour are the letters?
li {
text-align: left;
background-color: purple;
color: blue;
font-size: 32px;
} (a) red (b) purple (c) blue - 38.True or false: .star is an id selector. (a) True (b) False
-
39.🖌️ Where does the text sit on its line?
h1 {
background-color: yellow;
font-size: 20px;
text-align: right;
color: blue;
} (a) on the left (b) on the right (c) in the middle - 40.📦 In the box model, which part is the gap round content? (a) border (b) padding (c) content (d) margin
Answer key
- #
- margin
- white
- 350
- an id selector
- a class selector
- yellow
- packs boxes at the end
- red
- 10
- picks the font style
- orange
- True
- <p id="end">
- 10px
- 600px or narrower
- False
- rounds box corners
- sets colours and fonts
- fits every screen
- red
- li
- text-align
- Yes
- 255
- font-style
- blue
- purple
- F
- 20
- flex-start
- blue
- a class selector
- .
- 2
- yellow
- blue
- False
- on the right
- padding
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids