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 value is given to font-size in this rule?
h2 {
text-align: center;
font-size: 20px;
border: 2px solid;
width: 300px;
} (a) yellow (b) font-size (c) 20px (d) center - 2.💪 Which flexbox property turns on flexbox? (a) justify-content (b) flex-direction (c) display: flex (d) align-items
- 3.🌈 Which colour of light is strongest in rgb(18, 164, 78)? (a) red (b) green (c) blue
- 4.What does background-color do? (a) colours behind the text (b) picks the font style (c) sets the letter colour (d) makes the text bold
-
5.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 270px;
padding: 25px;
border: 2px solid black;
margin: 5px;
} -
6.🖌️ What colour is behind the letters?
li {
font-size: 36px;
color: blue;
background-color: purple;
text-align: left;
} (a) red (b) blue (c) purple - 7.🧩 Which language reacts to a button click? (a) CSS (b) HTML (c) JavaScript
-
8.✍️ What value is given to background-color in this rule?
#top {
font-style: italic;
background-color: yellow;
} (a) 8px (b) background-color (c) yellow (d) 10px -
9.🖌️ Where does the text sit on its line?
li {
font-size: 36px;
background-color: black;
text-align: center;
color: purple;
} (a) on the left (b) on the right (c) in the middle - 10.🎯 What kind of selector is body? (a) a class selector (b) an id selector (c) an element selector
- 11.💪 Which justify-content value packs boxes at the start? (a) flex-start (b) center (c) space-between (d) flex-end
-
12.🖌️ Where does the text sit on its line?
li {
font-size: 32px;
text-align: center;
color: blue;
background-color: yellow;
} (a) on the right (b) in the middle (c) on the left - 13.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the first one (c) neither (d) the shorter one
- 14.🖌️ Which CSS property picks the font style? (a) background-color (b) color (c) font-weight (d) font-family
- 15.🎨 What does CSS stand for? (a) Computer Style Sheets (b) Colourful Site Styles (c) Creative Sheet System (d) Cascading Style Sheets
- 16.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) turned off (c) exactly 1000px (d) 600px or narrower
- 17.📦 In the box model, which part is the gap to other boxes? (a) padding (b) margin (c) border (d) content
- 18.🎯 Which element does the selector .box style? (a) <div id="box"> (b) <span class="menu"> (c) <div class="star"> (d) <div class="box">
-
19.🖌️ Where does the text sit on its line?
h2 {
text-align: center;
background-color: black;
color: green;
font-size: 12px;
} (a) in the middle (b) on the left (c) on the right - 20.💪 Which flexbox property spaces boxes along a row? (a) flex-direction (b) justify-content (c) display: flex (d) gap
-
21.✍️ What value is given to border in this rule?
h1 {
border: 2px solid;
width: 300px;
text-align: center;
} (a) 2px solid (b) 300px (c) border (d) italic -
22.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 110px;
padding: 20px;
border: 4px solid black;
margin: 0px;
} - 23.💪 Which flexbox property lines boxes up across? (a) display: flex (b) justify-content (c) align-items (d) flex-direction
- 24.🎨 Which attribute adds CSS inside one tag? (a) src (b) alt (c) href (d) style
- 25.What does text-align do? (a) makes the text bold (b) centres a heading (c) sets the letter colour (d) makes letters bigger
- 26.True or false: JavaScript reacts to a button click. (a) False (b) True
- 27.True or false: padding is space outside the border. (a) True (b) False
-
28.⚖️ What colour is the text of this element?
<p class="big" id="top">Hi</p>
CSS:
#top { color: blue; }
.big { color: green; }
p { color: black; } (a) black (b) blue (c) green (d) orange - 29.True or false: the border is the line round the box. (a) False (b) True
-
30.📱 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;
}
} - 31.True or false: padding is the gap round content. (a) False (b) True
- 32.True or false: #main is an id selector. (a) True (b) False
-
33.🎯 Which CSS selector matches this element?
<p class="box" id="end">Hello</p> (a) h1 (b) #box (c) #hero (d) p -
34.✍️ How many declarations (property: value pairs) are in this rule?
li {
color: red;
width: 300px;
font-weight: bold;
} -
35.⚖️ What colour is the text of this element?
<h2 class="box" id="end">Hi</h2>
CSS:
h2 { color: green; }
h2 { color: white; } (a) yellow (b) black (c) white (d) green -
36.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 22px;
}
} -
37.⚖️ What colour is the text of this element?
<p class="note" id="main">Hi</p>
CSS:
#main { color: red; }
#main { color: green; } (a) yellow (b) red (c) white (d) green - 38.🎯 Which element does the selector h2 style? (a) <li> (b) <span id="top"> (c) <div class="star"> (d) <h2 class="star">
- 39.True or false: margin is the gap round content. (a) True (b) False
- 40.📦 In the box model, which part is the line round the box? (a) content (b) margin (c) padding (d) border
Answer key
- 20px
- display: flex
- green
- colours behind the text
- 324
- purple
- JavaScript
- yellow
- in the middle
- an element selector
- flex-start
- in the middle
- the later one
- font-family
- Cascading Style Sheets
- 600px or narrower
- margin
- <div class="box">
- in the middle
- justify-content
- 2px solid
- 158
- align-items
- style
- centres a heading
- True
- False
- blue
- True
- 16
- True
- True
- p
- 3
- white
- 22
- green
- <h2 class="star">
- False
- border
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids