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 is rgb(255, 255, 0)? (a) white (b) red (c) cyan (d) yellow
-
2.✍️ What value is given to border in this rule?
#top {
font-weight: bold;
text-align: center;
border: 2px solid;
margin: 10px;
} (a) italic (b) border (c) 2px solid (d) 300px -
3.⚖️ What colour is the text of this element?
<h2 class="big" id="hero">Hi</h2>
CSS:
h2 { color: yellow; }
#hero { color: blue; } (a) green (b) yellow (c) blue (d) white -
4.✍️ What value is given to text-align in this rule?
h2 {
font-weight: bold;
text-align: center;
} (a) yellow (b) 10px (c) center (d) text-align -
5.✍️ How many declarations (property: value pairs) are in this rule?
.box {
background-color: yellow;
border: 2px solid;
font-weight: bold;
} - 6.🖌️ Which CSS property colours behind the text? (a) text-align (b) font-weight (c) font-size (d) background-color
- 7.💪 Which justify-content value puts boxes in the middle? (a) space-between (b) flex-end (c) flex-start (d) center
-
8.✍️ How many declarations (property: value pairs) are in this rule?
li {
font-weight: bold;
width: 300px;
} - 9.🧩 Which language lays out the page? (a) CSS (b) HTML (c) JavaScript
- 10.🎯 What kind of selector is p? (a) an id selector (b) an element selector (c) a class selector
- 11.🔍 Which is the odd one out? (a) reacts to a button click (b) counts down a timer (c) shows a pop-up message (d) puts a picture on a page
- 12.🎨 A CSS file usually ends with which extension? (a) .png (b) .css (c) .html (d) .js
-
13.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 60px;
padding: 20px;
border: 5px solid black;
margin: 5px;
} - 14.True or false: JavaScript changes the page live. (a) True (b) False
-
15.⚖️ What colour is the text of this element?
<h1 class="note" id="top">Hi</h1>
CSS:
#top { color: white; }
#top { color: black; } (a) white (b) red (c) purple (d) black - 16.Which of these does CSS do? (a) makes headings and lists (b) gives the page structure (c) checks a quiz answer (d) sets colours and fonts
- 17.🌈 Which hex code is magenta? (a) #0000ff (b) #ff0000 (c) #00ff00 (d) #ff00ff
-
18.🖌️ Where does the text sit on its line?
h1 {
background-color: green;
text-align: left;
font-size: 20px;
color: purple;
} (a) on the left (b) on the right (c) in the middle - 19.🧩 Which language changes the text size? (a) HTML (b) JavaScript (c) CSS
-
20.📦 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: 30px;
border: 3px solid black;
margin: 15px;
} - 21.🎨 Which attribute adds CSS inside one tag? (a) alt (b) href (c) src (d) style
- 22.🌈 Which hex code is red? (a) #000000 (b) #ff0000 (c) #0000ff (d) #00ffff
-
23.✍️ What is the selector in this CSS rule?
li {
border: 2px solid;
font-size: 20px;
color: red;
padding: 8px;
} (a) body (b) 20px (c) border (d) li - 24.🎯 What kind of selector is body? (a) an id selector (b) an element selector (c) a class selector
- 25.🌈 Which colour is rgb(0, 0, 255)? (a) bright green (b) white (c) blue (d) red
- 26.💪 Which flexbox property lines boxes up across? (a) flex-direction (b) display: flex (c) align-items (d) gap
- 27.🎯 What kind of selector is li? (a) an id selector (b) a class selector (c) an element selector
- 28.🎯 What kind of selector is #logo? (a) a class selector (b) an id selector (c) an element selector
-
29.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 280px;
justify-content: center;
}
Inside are 3 boxes, each 40px wide (no margins). - 30.True or false: margin is space outside the border. (a) True (b) False
- 31.What does justify-content: space-between do? (a) puts boxes in the middle (b) packs boxes at the start (c) equal gaps, none at ends (d) packs boxes at the end
- 32.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or wider (c) 600px or narrower (d) turned off
-
33.🖌️ Where does the text sit on its line?
h1 {
background-color: blue;
text-align: right;
font-size: 40px;
color: purple;
} (a) on the right (b) in the middle (c) on the left - 34.🎯 What kind of selector is #end? (a) an element selector (b) a class selector (c) an id selector
-
35.🖌️ How big is the text, in px?
li {
color: green;
font-size: 20px;
text-align: center;
background-color: purple;
} -
36.⚖️ What colour is the text of this element?
<h2 class="red" id="intro">Hi</h2>
CSS:
#intro { color: red; }
#intro { color: yellow; } (a) black (b) yellow (c) purple (d) red - 37.Which of these does HTML do? (a) reacts to a button click (b) adds space around boxes (c) makes a link (d) changes the page live
- 38.🌈 Which colour of light is strongest in rgb(40, 200, 117)? (a) blue (b) green (c) red
-
39.⚖️ What colour is the text of this element?
<p class="red" id="top">Hi</p>
CSS:
#top { color: yellow; }
.red { color: orange; }
p { color: purple; } (a) white (b) orange (c) purple (d) yellow -
40.🖌️ How big is the text, in px?
h1 {
text-align: right;
font-size: 36px;
background-color: green;
color: blue;
}
Answer key
- yellow
- 2px solid
- blue
- center
- 3
- background-color
- center
- 2
- CSS
- an element selector
- puts a picture on a page
- .css
- 120
- True
- black
- sets colours and fonts
- #ff00ff
- on the left
- CSS
- 336
- style
- #ff0000
- li
- an element selector
- blue
- align-items
- an element selector
- an id selector
- 80
- True
- equal gaps, none at ends
- 600px or narrower
- on the right
- an id selector
- 20
- yellow
- makes a link
- green
- yellow
- 36
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids