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 justify-content: center do? (a) puts boxes in the middle (b) packs boxes at the end (c) equal gaps, none at ends (d) packs boxes at the start
- 2.True or false: margin is the gap to other boxes. (a) True (b) False
- 3.🔍 Which is the odd one out? (a) lays out the page (b) makes headings and lists (c) gives the page structure (d) makes a form box
- 4.🎯 Which element does the selector #main style? (a) <h2 class="main"> (b) <h2 id="logo"> (c) <li class="big"> (d) <h2 id="main">
- 5.🌈 Which colour is rgb(0, 0, 255)? (a) blue (b) magenta (c) bright green (d) red
- 6.🌈 Which hex code is yellow? (a) #0000ff (b) #ffff00 (c) #000000 (d) #ff00ff
-
7.🖌️ What colour are the letters?
p {
font-size: 32px;
text-align: right;
background-color: yellow;
color: blue;
} (a) yellow (b) blue (c) purple - 8.🌈 In #000034 the blue part is the hex number 34. What is it as a normal number?
- 9.🎯 How many elements on a page should have the same id? (a) 5 (b) 1 (c) 2 (d) any number
- 10.True or false: HTML gives the page structure. (a) True (b) False
- 11.🖌️ Which CSS property sets the letter colour? (a) color (b) background-color (c) font-weight (d) font-family
-
12.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 150px;
justify-content: flex-start;
}
Inside are 2 boxes, each 40px wide (no margins). - 13.🌈 Which colour is rgb(0, 0, 0)? (a) white (b) black (c) blue (d) bright green
- 14.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) white (c) green (d) red
-
15.✍️ What is the selector in this CSS rule?
p {
padding: 8px;
width: 300px;
margin: 10px;
} (a) 300px (b) padding (c) p (d) .note -
16.⚖️ What colour is the text of this element?
<p class="menu" id="main">Hi</p>
CSS:
p { color: red; }
p { color: green; } (a) blue (b) black (c) green (d) red - 17.🔍 Which is the odd one out? (a) sets colours and fonts (b) changes the text size (c) adds space around boxes (d) makes headings and lists
-
18.🖌️ What colour are the letters?
h2 {
font-size: 36px;
background-color: blue;
color: yellow;
text-align: left;
} (a) blue (b) red (c) yellow - 19.True or false: CSS rounds box corners. (a) True (b) False
-
20.✍️ Which property is set to yellow in this rule?
h2 {
padding: 8px;
background-color: yellow;
width: 300px;
} (a) margin (b) padding (c) yellow (d) background-color -
21.🎯 Which CSS selector matches this element?
<li class="box" id="intro">Hello</li> (a) #intro (b) #main (c) div (d) #box - 22.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
-
23.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 140px;
justify-content: space-between;
}
Inside are 2 boxes, each 50px wide (no margins). - 24.✍️ Which sign goes between a property and its value? (a) - (b) = (c) : (d) ;
- 25.🌈 Which colour of light is strongest in rgb(61, 136, 222)? (a) red (b) green (c) blue
-
26.⚖️ What colour is the text of this element?
<p class="menu" id="logo">Hi</p>
CSS:
.menu { color: white; }
#logo { color: red; }
p { color: black; } (a) black (b) blue (c) red (d) white - 27.What does font-weight do? (a) makes letters bigger (b) centres a heading (c) makes the text bold (d) colours behind the text
-
28.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 6px;
}
} (a) No (b) Yes - 29.🌈 Which colour is #00ffff? (a) black (b) cyan (c) blue (d) magenta
- 30.🌈 Which colour of light is strongest in rgb(11, 235, 83)? (a) red (b) blue (c) green
-
31.⚖️ What colour is the text of this element?
<h1 class="red" id="end">Hi</h1>
CSS:
.red { color: red; }
#end { color: blue; }
h1 { color: white; } (a) blue (b) white (c) red (d) green -
32.🎯 Which CSS selector matches this element?
<div class="red" id="end">Hello</div> (a) #red (b) span (c) .end (d) .red - 33.🖌️ Which CSS property colours behind the text? (a) font-size (b) color (c) background-color (d) font-weight
- 34.🌈 In #rrggbb, which colour do the first two digits give? (a) blue (b) green (c) red (d) black
- 35.Which of these is margin? (a) a solid or dotted edge (b) the text or picture (c) the gap to other boxes (d) the gap round content
- 36.🎯 Which element does the selector .red style? (a) <h1 class="box"> (b) <h2 class="star"> (c) <h1 class="red"> (d) <h1 id="red">
-
37.✍️ What is the selector in this CSS rule?
body {
font-weight: bold;
background-color: yellow;
text-align: center;
} (a) .box (b) body (c) font-weight (d) yellow -
38.🖌️ What colour are the letters?
li {
background-color: white;
color: blue;
font-size: 40px;
text-align: left;
} (a) blue (b) white (c) purple -
39.🎯 Which CSS selector matches this element?
<h2 class="note" id="top">Hello</h2> (a) .big (b) #note (c) h2 (d) .top -
40.🖌️ Where does the text sit on its line?
li {
background-color: red;
font-size: 12px;
text-align: left;
color: blue;
} (a) on the right (b) on the left (c) in the middle
Answer key
- puts boxes in the middle
- True
- lays out the page
- <h2 id="main">
- blue
- #ffff00
- blue
- 52
- 1
- True
- color
- 70
- black
- blue
- p
- green
- makes headings and lists
- yellow
- True
- background-color
- #intro
- an element selector
- 40
- :
- blue
- red
- makes the text bold
- Yes
- cyan
- green
- blue
- .red
- background-color
- red
- the gap to other boxes
- <h1 class="red">
- body
- blue
- h2
- on the left
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids