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 colour of light is strongest in rgb(81, 160, 85)? (a) red (b) green (c) blue
-
2.🎯 Which CSS selector matches this element?
<h1 class="big" id="logo">Hello</h1> (a) .logo (b) h1 (c) h2 (d) #end - 3.What does font-size do? (a) sets the letter colour (b) picks the font style (c) makes letters bigger (d) colours behind the text
- 4.🌈 What is the biggest number one colour can have in rgb()? (a) 1000 (b) 100 (c) 255 (d) 99
-
5.⚖️ What colour is the text of this element?
<h2 class="big" id="logo">Hi</h2>
CSS:
.big { color: white; }
#logo { color: black; } (a) white (b) green (c) black (d) red -
6.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 24px;
}
} -
7.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 24px;
}
} (a) No (b) Yes - 8.What does background-color do? (a) sets the letter colour (b) colours behind the text (c) makes the text bold (d) centres a heading
-
9.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
text-align: center;
width: 300px;
} - 10.🌈 Which colour is #00ff00? (a) blue (b) bright green (c) magenta (d) black
- 11.✍️ In color: blue; which part is the value? (a) color (b) ; (c) : (d) blue
- 12.🎯 Can many elements share the same class? (a) No (b) Yes
- 13.What does justify-content: space-between do? (a) packs boxes at the start (b) equal gaps, none at ends (c) puts boxes in the middle (d) packs boxes at the end
- 14.True or false: HTML makes a link. (a) True (b) False
- 15.Which of these does HTML do? (a) reacts to a button click (b) puts a picture on a page (c) adds space around boxes (d) shows a pop-up message
-
16.✍️ What is the selector in this CSS rule?
#top {
font-size: 20px;
border: 2px solid;
} (a) font-size (b) #top (c) 2px solid (d) li - 17.Which of these is the border? (a) a solid or dotted edge (b) the gap to other boxes (c) space outside the border (d) the text or picture
-
18.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 320px;
justify-content: flex-start;
}
Inside are 4 boxes, each 60px wide (no margins). - 19.🌈 In #rrggbb, which colour do the last two digits give? (a) white (b) green (c) blue (d) red
-
20.⚖️ What colour is the text of this element?
<h2 class="note" id="hero">Hi</h2>
CSS:
.note { color: orange; }
.note { color: yellow; } (a) yellow (b) red (c) orange (d) white -
21.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 230px;
justify-content: flex-end;
}
Inside are 3 boxes, each 50px wide (no margins). -
22.⚖️ What colour is the text of this element?
<p class="note" id="hero">Hi</p>
CSS:
.note { color: white; }
.note { color: blue; } (a) white (b) blue (c) red (d) black -
23.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 200px;
padding: 5px;
border: 5px solid black;
margin: 0px;
} -
24.✍️ How many declarations (property: value pairs) are in this rule?
li {
background-color: yellow;
width: 300px;
text-align: center;
font-style: italic;
} - 25.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the later one (c) the shorter one (d) neither
-
26.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 340px;
justify-content: flex-start;
}
Inside are 3 boxes, each 100px wide (no margins). -
27.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 200px;
justify-content: flex-end;
}
Inside are 3 boxes, each 40px wide (no margins). - 28.📱 What does a media query check? (a) the screen width (b) the time of day (c) the battery level (d) the page title
- 29.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
- 30.🌈 Which colour is #ff0000? (a) magenta (b) black (c) blue (d) red
-
31.🎯 Which CSS selector matches this element?
<div class="red" id="end">Hello</div> (a) #hero (b) #red (c) #end (d) .end - 32.🎯 Which element does the selector #end style? (a) <li class="end"> (b) <li id="end"> (c) <li id="hero"> (d) <div class="box">
- 33.🌈 Which colour of light is strongest in rgb(29, 49, 208)? (a) blue (b) green (c) red
- 34.What does font-family do? (a) makes the text bold (b) sets the letter colour (c) colours behind the text (d) picks the font style
-
35.✍️ What value is given to font-style in this rule?
.note {
text-align: center;
font-style: italic;
padding: 8px;
} (a) 20px (b) font-style (c) italic (d) red -
36.⚖️ What colour is the text of this element?
<p class="note" id="main">Hi</p>
CSS:
p { color: blue; }
p { color: white; } (a) white (b) orange (c) blue (d) black -
37.🖌️ What colour is behind the letters?
h2 {
text-align: center;
font-size: 28px;
background-color: orange;
color: red;
} (a) orange (b) blue (c) red -
38.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 18px;
}
} (a) No (b) Yes - 39.✍️ CSS declarations go inside which brackets? (a) [ ] (b) < > (c) { } (d) ( )
- 40.🌈 Which colour is rgb(255, 255, 0)? (a) white (b) bright green (c) black (d) yellow
Answer key
- green
- h1
- makes letters bigger
- 255
- black
- 24
- Yes
- colours behind the text
- 2
- bright green
- blue
- Yes
- equal gaps, none at ends
- True
- puts a picture on a page
- #top
- a solid or dotted edge
- 80
- blue
- yellow
- 80
- blue
- 220
- 4
- the later one
- 40
- 80
- the screen width
- an id selector
- red
- #end
- <li id="end">
- blue
- picks the font style
- italic
- white
- orange
- Yes
- { }
- yellow
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids