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 selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
-
2.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 6px;
}
} -
3.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 12px;
}
} (a) No (b) Yes - 4.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) turned off (c) exactly 1000px (d) 600px or narrower
- 5.🌈 In #rrggbb, which colour do the first two digits give? (a) red (b) blue (c) black (d) green
-
6.⚖️ What colour is the text of this element?
<p class="note" id="top">Hi</p>
CSS:
#top { color: white; }
#top { color: green; } (a) red (b) white (c) purple (d) green - 7.💪 Which justify-content value packs boxes at the start? (a) flex-start (b) center (c) flex-end (d) space-between
- 8.✍️ Which sign goes between a property and its value? (a) = (b) : (c) - (d) ;
- 9.🌈 Which colour is rgb(255, 0, 0)? (a) blue (b) red (c) white (d) bright green
-
10.✍️ What is the selector in this CSS rule?
#top {
width: 300px;
margin: 10px;
border: 2px solid;
font-style: italic;
} (a) #top (b) li (c) width (d) 10px - 11.🌈 Which colour of light is strongest in rgb(86, 83, 198)? (a) green (b) blue (c) red
-
12.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 18px;
}
} (a) Yes (b) No - 13.What does text-align do? (a) makes the text bold (b) makes letters bigger (c) colours behind the text (d) centres a heading
-
14.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 370px;
justify-content: space-between;
}
Inside are 4 boxes, each 40px wide (no margins). -
15.⚖️ What colour is the text of this element?
<h2 class="big" id="top">Hi</h2>
CSS:
h2 { color: green; }
h2 { color: orange; } (a) yellow (b) orange (c) blue (d) green -
16.🖌️ What colour is behind the letters?
li {
background-color: orange;
text-align: center;
font-size: 32px;
color: yellow;
} (a) yellow (b) orange (c) red - 17.🌈 Which colour of light is strongest in rgb(66, 120, 178)? (a) green (b) blue (c) red
- 18.True or false: padding is space outside the border. (a) True (b) False
-
19.✍️ What is the selector in this CSS rule?
#top {
font-weight: bold;
border: 2px solid;
} (a) #top (b) 2px solid (c) li (d) font-weight - 20.💪 Which justify-content value equal gaps, none at ends? (a) flex-end (b) center (c) space-between (d) flex-start
- 21.⚖️ 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
-
22.⚖️ What colour is the text of this element?
<h1 class="note" id="intro">Hi</h1>
CSS:
h1 { color: green; }
#intro { color: black; } (a) purple (b) white (c) green (d) black -
23.⚖️ What colour is the text of this element?
<p class="star" id="end">Hi</p>
CSS:
#end { color: red; }
p { color: white; } (a) white (b) orange (c) red (d) green -
24.⚖️ What colour is the text of this element?
<p class="box" id="top">Hi</p>
CSS:
.box { color: red; }
.box { color: blue; } (a) red (b) yellow (c) blue (d) green - 25.🎯 Which sign starts a class selector? (a) . (b) @ (c) & (d) #
- 26.🎯 Which element does the selector span style? (a) <span class="note"> (b) <p> (c) <h1 class="note"> (d) <h2 id="logo">
-
27.🖌️ What colour is behind the letters?
p {
text-align: right;
font-size: 12px;
color: red;
background-color: yellow;
} (a) red (b) yellow (c) orange - 28.Which of these does JavaScript do? (a) reacts to a button click (b) adds space around boxes (c) rounds box corners (d) lays out the page
- 29.True or false: .card is an element selector. (a) False (b) True
-
30.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 50px;
padding: 10px;
border: 1px solid black;
margin: 15px;
} -
31.🖌️ What colour is behind the letters?
h2 {
font-size: 32px;
color: purple;
text-align: left;
background-color: black;
} (a) purple (b) blue (c) black - 32.🌈 In #00da00 the green part is the hex number da. What is it as a normal number?
-
33.🖌️ Where does the text sit on its line?
li {
font-size: 16px;
background-color: yellow;
color: red;
text-align: center;
} (a) on the left (b) on the right (c) in the middle - 34.🌈 Which colour is #ff00ff? (a) cyan (b) blue (c) white (d) magenta
- 35.💪 Which flexbox property lines boxes up across? (a) justify-content (b) gap (c) flex-direction (d) align-items
-
36.⚖️ What colour is the text of this element?
<p class="menu" id="hero">Hi</p>
CSS:
#hero { color: yellow; }
#hero { color: blue; } (a) yellow (b) red (c) purple (d) blue - 37.🌈 Which colour is rgb(255, 0, 255)? (a) cyan (b) yellow (c) magenta (d) bright green
-
38.🎯 Which CSS selector matches this element?
<h1 class="menu" id="end">Hello</h1> (a) h2 (b) .end (c) .note (d) .menu -
39.🖌️ What colour are the letters?
h2 {
font-size: 32px;
background-color: blue;
text-align: center;
color: orange;
} (a) white (b) orange (c) blue -
40.✍️ What value is given to font-weight in this rule?
p {
font-weight: bold;
color: red;
text-align: center;
} (a) 2px solid (b) 300px (c) font-weight (d) bold
Answer key
- an id selector
- 6
- Yes
- 600px or narrower
- red
- green
- flex-start
- :
- red
- #top
- blue
- No
- centres a heading
- 70
- orange
- orange
- blue
- False
- #top
- space-between
- the later one
- black
- red
- blue
- .
- <span class="note">
- yellow
- reacts to a button click
- False
- 102
- black
- 218
- in the middle
- magenta
- align-items
- blue
- magenta
- .menu
- orange
- bold
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids