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.🖌️ Where does the text sit on its line?
h1 {
text-align: left;
color: green;
font-size: 16px;
background-color: purple;
} (a) in the middle (b) on the left (c) on the right -
2.✍️ How many declarations (property: value pairs) are in this rule?
#top {
font-weight: bold;
font-size: 20px;
border: 2px solid;
} - 3.🌈 Hex digits go 0 to 9, then A to which letter? (a) Z (b) F (c) G (d) J
-
4.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 220px;
justify-content: flex-start;
}
Inside are 3 boxes, each 50px wide (no margins). - 5.What does justify-content: space-between do? (a) equal gaps, none at ends (b) packs boxes at the end (c) packs boxes at the start (d) puts boxes in the middle
- 6.🎨 Which tag connects an outside CSS file? (a) <a> (b) <img> (c) <link> (d) <css>
- 7.💪 Which justify-content value packs boxes at the start? (a) center (b) space-between (c) flex-start (d) flex-end
- 8.🎯 Which sign starts an id selector? (a) & (b) # (c) @ (d) .
- 9.True or false: JavaScript counts down a timer. (a) False (b) True
- 10.🌈 Which hex code is red? (a) #ffffff (b) #ffff00 (c) #000000 (d) #ff0000
-
11.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 220px;
justify-content: flex-start;
}
Inside are 4 boxes, each 40px wide (no margins). - 12.🔍 Which is the odd one out? (a) makes headings and lists (b) puts a picture on a page (c) adds space around boxes (d) makes a link
-
13.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 200px;
justify-content: center;
}
Inside are 2 boxes, each 40px wide (no margins). - 14.🌈 Which colour is rgb(255, 255, 255)? (a) white (b) cyan (c) black (d) magenta
-
15.⚖️ What colour is the text of this element?
<h1 class="menu" id="hero">Hi</h1>
CSS:
h1 { color: white; }
#hero { color: green; } (a) white (b) red (c) black (d) green -
16.⚖️ What colour is the text of this element?
<p class="star" id="hero">Hi</p>
CSS:
p { color: red; }
p { color: black; } (a) blue (b) black (c) purple (d) red -
17.⚖️ What colour is the text of this element?
<p class="box" id="main">Hi</p>
CSS:
#main { color: orange; }
#main { color: red; } (a) red (b) white (c) orange (d) green - 18.🎯 What kind of selector is h1? (a) an id selector (b) a class selector (c) an element selector
- 19.What does color do? (a) centres a heading (b) sets the letter colour (c) colours behind the text (d) makes the text bold
-
20.🖌️ What colour are the letters?
h1 {
color: blue;
text-align: center;
font-size: 24px;
background-color: purple;
} (a) blue (b) orange (c) purple - 21.🎯 Which element does the selector div style? (a) <span> (b) <div class="red"> (c) <p class="red"> (d) <h1 id="top">
- 22.True or false: img is an id selector. (a) False (b) True
-
23.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 22px;
}
} (a) Yes (b) No - 24.True or false: .star is a class selector. (a) True (b) False
- 25.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or narrower (c) turned off (d) 600px or wider
-
26.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 230px;
padding: 5px;
border: 1px solid black;
margin: 15px;
} -
27.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 768px) {
p {
font-size: 26px;
}
} (a) Yes (b) No -
28.✍️ Which property is set to italic in this rule?
.box {
font-style: italic;
text-align: center;
color: red;
} (a) font-size (b) font-style (c) color (d) italic -
29.✍️ Which property is set to 20px in this rule?
p {
text-align: center;
color: red;
font-size: 20px;
border: 2px solid;
} (a) text-align (b) font-size (c) 20px (d) background-color - 30.🖌️ Which CSS property centres a heading? (a) text-align (b) font-size (c) color (d) font-family
- 31.🔍 Which is the odd one out? (a) counts down a timer (b) changes the page live (c) shows a pop-up message (d) puts a picture on a page
-
32.✍️ Which property is set to bold in this rule?
li {
background-color: yellow;
font-weight: bold;
} (a) font-weight (b) border (c) bold (d) width -
33.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 100px;
padding: 20px;
border: 3px solid black;
margin: 10px;
} - 34.✍️ In color: blue; which part is the property? (a) : (b) blue (c) ; (d) color
- 35.Which of these does JavaScript do? (a) makes headings and lists (b) reacts to a button click (c) lays out the page (d) gives the page structure
- 36.True or false: the border is the line round the box. (a) True (b) False
-
37.🖌️ How big is the text, in px?
h1 {
font-size: 32px;
text-align: left;
color: orange;
background-color: white;
} - 38.🎨 What does CSS stand for? (a) Colourful Site Styles (b) Cascading Style Sheets (c) Creative Sheet System (d) Computer Style Sheets
-
39.✍️ What value is given to background-color in this rule?
.box {
background-color: yellow;
width: 300px;
} (a) background-color (b) 10px (c) yellow (d) 8px -
40.⚖️ What colour is the text of this element?
<p class="red" id="end">Hi</p>
CSS:
#end { color: white; }
#end { color: green; } (a) green (b) blue (c) white (d) black
Answer key
- on the left
- 3
- F
- 70
- equal gaps, none at ends
- <link>
- flex-start
- #
- True
- #ff0000
- 60
- adds space around boxes
- 60
- white
- green
- black
- red
- an element selector
- sets the letter colour
- blue
- <div class="red">
- False
- Yes
- True
- 600px or narrower
- 242
- No
- font-style
- font-size
- text-align
- puts a picture on a page
- font-weight
- 166
- color
- reacts to a button click
- True
- 32
- Cascading Style Sheets
- yellow
- green
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids