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.✍️ In color: blue; which part is the value? (a) : (b) ; (c) color (d) blue
-
2.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 320px;
justify-content: flex-end;
}
Inside are 4 boxes, each 60px wide (no margins). - 3.🎨 A CSS file usually ends with which extension? (a) .png (b) .css (c) .html (d) .js
- 4.🌈 Which colour is #000000? (a) white (b) bright green (c) blue (d) black
- 5.🧩 Which language lays out the page? (a) JavaScript (b) HTML (c) CSS
- 6.🌈 Which hex code is bright green? (a) #ffff00 (b) #00ff00 (c) #000000 (d) #ffffff
-
7.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 20px;
}
} -
8.🖌️ What colour are the letters?
h2 {
font-size: 36px;
text-align: left;
background-color: green;
color: purple;
} (a) green (b) yellow (c) purple -
9.✍️ What value is given to color in this rule?
li {
font-style: italic;
padding: 8px;
color: red;
} (a) color (b) red (c) center (d) 20px - 10.🌈 Which colour is #0000ff? (a) red (b) blue (c) yellow (d) white
-
11.🖌️ What colour is behind the letters?
h2 {
text-align: center;
font-size: 16px;
color: green;
background-color: red;
} (a) green (b) red (c) purple - 12.🖌️ Which CSS property picks the font style? (a) text-align (b) font-weight (c) font-size (d) font-family
-
13.✍️ What is the selector in this CSS rule?
#top {
margin: 10px;
font-weight: bold;
text-align: center;
} (a) margin (b) li (c) #top (d) bold -
14.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 140px;
padding: 30px;
border: 1px solid black;
margin: 15px;
} - 15.🌈 Which colour is #ffffff? (a) white (b) blue (c) bright green (d) magenta
- 16.Which of these does HTML do? (a) gives the page structure (b) sets colours and fonts (c) checks a quiz answer (d) shows a pop-up message
- 17.Which of these does JavaScript do? (a) changes the text size (b) reacts to a button click (c) sets colours and fonts (d) puts a picture on a page
-
18.🎯 Which CSS selector matches this element?
<div class="star" id="hero">Hello</div> (a) .hero (b) .star (c) #top (d) span - 19.What does font-family do? (a) picks the font style (b) sets the letter colour (c) makes the text bold (d) colours behind the text
-
20.⚖️ What colour is the text of this element?
<h2 class="red" id="main">Hi</h2>
CSS:
#main { color: blue; }
h2 { color: green; }
.red { color: red; } (a) green (b) blue (c) red (d) white - 21.✍️ Which sign ends each CSS declaration? (a) : (b) ; (c) . (d) ,
-
22.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 80px;
padding: 30px;
border: 1px solid black;
margin: 0px;
} -
23.📦 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: 20px;
} - 24.💪 Which flexbox property spaces boxes along a row? (a) align-items (b) justify-content (c) display: flex (d) flex-direction
- 25.True or false: CSS changes the text size. (a) True (b) False
- 26.🧩 Which language adds space around boxes? (a) JavaScript (b) HTML (c) CSS
-
27.⚖️ What colour is the text of this element?
<h2 class="star" id="top">Hi</h2>
CSS:
h2 { color: orange; }
#top { color: blue; }
.star { color: red; } (a) orange (b) yellow (c) red (d) blue -
28.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 230px;
justify-content: flex-start;
}
Inside are 2 boxes, each 100px wide (no margins). - 29.🎯 What kind of selector is #hero? (a) an id selector (b) a class selector (c) an element selector
-
30.🖌️ How big is the text, in px?
h1 {
font-size: 28px;
color: orange;
text-align: right;
background-color: white;
} - 31.📱 What does a media query check? (a) the time of day (b) the battery level (c) the page title (d) the screen width
- 32.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
-
33.⚖️ What colour is the text of this element?
<h1 class="note" id="intro">Hi</h1>
CSS:
#intro { color: blue; }
h1 { color: orange; }
.note { color: white; } (a) white (b) orange (c) yellow (d) blue - 34.🎯 Which sign starts an id selector? (a) & (b) @ (c) # (d) .
-
35.🎯 Which CSS selector matches this element?
<h1 class="note" id="main">Hello</h1> (a) .note (b) .main (c) h2 (d) .big - 36.What does font-size do? (a) makes the text bold (b) makes letters bigger (c) picks the font style (d) sets the letter colour
-
37.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 50px;
padding: 10px;
border: 3px solid black;
margin: 5px;
} -
38.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 320px;
justify-content: space-between;
}
Inside are 3 boxes, each 100px wide (no margins). - 39.🎨 Which tag holds CSS inside the head? (a) <style> (b) <css> (c) <script> (d) <body>
- 40.🎯 Which sign starts a class selector? (a) & (b) . (c) @ (d) #
Answer key
- blue
- 80
- .css
- black
- CSS
- #00ff00
- 16
- purple
- red
- blue
- red
- font-family
- #top
- 202
- white
- gives the page structure
- reacts to a button click
- .star
- picks the font style
- blue
- ;
- 142
- 242
- justify-content
- True
- CSS
- blue
- 30
- an id selector
- 28
- the screen width
- an element selector
- blue
- #
- .note
- makes letters bigger
- 86
- 10
- <style>
- .
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids