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.What does background-color do? (a) sets the letter colour (b) makes the text bold (c) picks the font style (d) colours behind the text
-
2.🖌️ What colour are the letters?
h2 {
background-color: orange;
color: purple;
font-size: 28px;
text-align: center;
} (a) purple (b) orange (c) black - 3.🎯 Which sign starts an id selector? (a) @ (b) . (c) & (d) #
- 4.🌈 Which colour is #0000ff? (a) cyan (b) white (c) blue (d) magenta
- 5.🖌️ Which CSS property sets the letter colour? (a) background-color (b) color (c) font-family (d) font-weight
- 6.📱 Responsive design means a page ___. (a) never changes (b) has no pictures (c) is only for laptops (d) fits every screen
- 7.🔍 Which is the odd one out? (a) shows a pop-up message (b) changes the page live (c) puts a picture on a page (d) reacts to a button click
- 8.💪 Which justify-content value packs boxes at the start? (a) space-between (b) center (c) flex-start (d) flex-end
- 9.🌈 Which colour of light is strongest in rgb(44, 201, 33)? (a) blue (b) green (c) red
- 10.🎯 What kind of selector is .note? (a) an id selector (b) an element selector (c) a class selector
- 11.What does justify-content: flex-end do? (a) puts boxes in the middle (b) equal gaps, none at ends (c) packs boxes at the start (d) packs boxes at the end
- 12.🎯 Can many elements share the same class? (a) Yes (b) No
-
13.⚖️ What colour is the text of this element?
<h2 class="note" id="end">Hi</h2>
CSS:
#end { color: black; }
#end { color: green; } (a) blue (b) green (c) yellow (d) black - 14.🎯 What kind of selector is #end? (a) an id selector (b) a class selector (c) an element selector
- 15.True or false: padding is space inside the border. (a) False (b) True
- 16.✍️ How does a CSS comment start? (a) <!-- (b) /* (c) // (d) #
- 17.🌈 In #0f0000 the red part is the hex number 0f. What is it as a normal number?
- 18.✍️ In color: blue; which part is the value? (a) color (b) : (c) blue (d) ;
-
19.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 12px;
}
} -
20.✍️ Which property is set to 300px in this rule?
#top {
text-align: center;
width: 300px;
} (a) font-style (b) color (c) width (d) 300px - 21.📱 What does a media query check? (a) the page title (b) the screen width (c) the time of day (d) the battery level
-
22.✍️ What is the selector in this CSS rule?
#top {
background-color: yellow;
font-weight: bold;
font-size: 20px;
margin: 10px;
} (a) li (b) bold (c) #top (d) background-color - 23.What does font-family do? (a) makes the text bold (b) picks the font style (c) centres a heading (d) makes letters bigger
- 24.🎯 What kind of selector is li? (a) an element selector (b) a class selector (c) an id selector
- 25.Which of these is the content? (a) the gap round content (b) the text or picture (c) a solid or dotted edge (d) the line round the box
-
26.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 220px;
justify-content: center;
}
Inside are 2 boxes, each 80px wide (no margins). -
27.⚖️ What colour is the text of this element?
<h1 class="box" id="intro">Hi</h1>
CSS:
#intro { color: green; }
.box { color: purple; }
h1 { color: blue; } (a) blue (b) white (c) purple (d) green - 28.🎯 What kind of selector is #top? (a) a class selector (b) an element selector (c) an id selector
- 29.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) blue (c) white (d) green
- 30.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the first one (c) the later one (d) neither
-
31.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 10px;
}
} (a) No (b) Yes -
32.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 340px;
justify-content: center;
}
Inside are 4 boxes, each 60px wide (no margins). - 33.True or false: CSS reacts to a button click. (a) False (b) True
-
34.🎯 Which CSS selector matches this element?
<li class="note" id="top">Hello</li> (a) .top (b) li (c) div (d) #intro - 35.What does font-weight do? (a) makes the text bold (b) colours behind the text (c) sets the letter colour (d) centres a heading
- 36.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 3 (b) 2 (c) 4 (d) 6
- 37.🌈 Which hex code is yellow? (a) #00ff00 (b) #000000 (c) #ffff00 (d) #ff00ff
- 38.💪 Which flexbox property spaces boxes along a row? (a) align-items (b) flex-direction (c) gap (d) justify-content
-
39.⚖️ What colour is the text of this element?
<h1 class="red" id="hero">Hi</h1>
CSS:
#hero { color: black; }
#hero { color: blue; } (a) black (b) blue (c) white (d) red -
40.⚖️ What colour is the text of this element?
<h1 class="red" id="logo">Hi</h1>
CSS:
#logo { color: white; }
h1 { color: red; }
.red { color: blue; } (a) blue (b) red (c) purple (d) white
Answer key
- colours behind the text
- purple
- #
- blue
- color
- fits every screen
- puts a picture on a page
- flex-start
- green
- a class selector
- packs boxes at the end
- Yes
- green
- an id selector
- True
- /*
- 15
- blue
- 16
- width
- the screen width
- #top
- picks the font style
- an element selector
- the text or picture
- 30
- green
- an id selector
- blue
- the later one
- Yes
- 50
- False
- li
- makes the text bold
- 3
- #ffff00
- justify-content
- blue
- white
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids