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 #710000 the red part is the hex number 71. What is it as a normal number?
-
2.🎯 Which CSS selector matches this element?
<p class="menu" id="top">Hello</p> (a) h1 (b) #intro (c) #menu (d) .menu -
3.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 220px;
justify-content: center;
}
Inside are 2 boxes, each 60px wide (no margins). -
4.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 180px;
padding: 15px;
border: 5px solid black;
margin: 15px;
} - 5.True or false: #main is an element selector. (a) False (b) True
- 6.True or false: JavaScript changes the text size. (a) True (b) False
-
7.🖌️ What colour are the letters?
p {
font-size: 28px;
color: green;
text-align: left;
background-color: red;
} (a) red (b) green (c) black -
8.🎯 Which CSS selector matches this element?
<p class="note" id="main">Hello</p> (a) .main (b) h1 (c) #note (d) #main - 9.📱 What does a media query check? (a) the battery level (b) the page title (c) the screen width (d) the time of day
- 10.✍️ In color: blue; which part is the property? (a) ; (b) : (c) color (d) blue
- 11.🔍 Which is the odd one out? (a) adds space around boxes (b) shows a pop-up message (c) changes the page live (d) reacts to a button click
- 12.🖌️ Which CSS property centres a heading? (a) text-align (b) font-weight (c) color (d) font-family
- 13.📱 Responsive design means a page ___. (a) fits every screen (b) never changes (c) has no pictures (d) is only for laptops
- 14.🎯 Which element does the selector .note style? (a) <h2 id="note"> (b) <h2 class="note"> (c) <li class="red"> (d) <h2 class="big">
-
15.🖌️ How big is the text, in px?
h2 {
font-size: 36px;
background-color: purple;
color: green;
text-align: left;
} - 16.🧩 Which language lays out the page? (a) CSS (b) JavaScript (c) HTML
- 17.True or false: .star is a class selector. (a) True (b) False
-
18.✍️ What value is given to text-align in this rule?
#top {
font-style: italic;
width: 300px;
font-size: 20px;
text-align: center;
} (a) text-align (b) yellow (c) 10px (d) center -
19.✍️ What value is given to font-weight in this rule?
h2 {
font-size: 20px;
font-style: italic;
text-align: center;
font-weight: bold;
} (a) font-weight (b) bold (c) 300px (d) 2px solid -
20.⚖️ What colour is the text of this element?
<p class="star" id="logo">Hi</p>
CSS:
.star { color: white; }
p { color: orange; }
#logo { color: black; } (a) white (b) black (c) orange (d) blue - 21.🧩 Which language puts a picture on a page? (a) HTML (b) CSS (c) JavaScript
-
22.✍️ Which property is set to 300px in this rule?
li {
width: 300px;
font-weight: bold;
} (a) 300px (b) font-style (c) color (d) width -
23.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 240px;
justify-content: flex-start;
}
Inside are 2 boxes, each 100px wide (no margins). -
24.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 300px;
padding: 20px;
border: 4px solid black;
margin: 20px;
} -
25.🎯 Which CSS selector matches this element?
<span class="star" id="top">Hello</span> (a) #intro (b) #star (c) .menu (d) .star - 26.🔍 Which is the odd one out? (a) checks a quiz answer (b) shows a pop-up message (c) sets colours and fonts (d) changes the page live
- 27.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the later one (c) neither (d) the first one
-
28.✍️ What value is given to margin in this rule?
#top {
font-style: italic;
text-align: center;
margin: 10px;
} (a) 8px (b) bold (c) 10px (d) margin - 29.📦 In the box model, which part is the gap to other boxes? (a) content (b) border (c) margin (d) padding
- 30.🔍 Which is the odd one out? (a) makes a form box (b) puts a picture on a page (c) gives the page structure (d) lays out the page
- 31.📦 In the box model, which part is a solid or dotted edge? (a) padding (b) margin (c) border (d) content
-
32.✍️ How many declarations (property: value pairs) are in this rule?
p {
background-color: yellow;
} - 33.💪 Which flexbox property sets space between boxes? (a) justify-content (b) display: flex (c) align-items (d) gap
-
34.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 22px;
}
} - 35.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) 800px or wider (c) 800px or narrower (d) exactly 100px
- 36.What does text-align do? (a) makes the text bold (b) picks the font style (c) centres a heading (d) makes letters bigger
- 37.🌈 Which colour is rgb(255, 0, 255)? (a) yellow (b) magenta (c) red (d) black
-
38.✍️ Which property is set to 2px solid in this rule?
p {
background-color: yellow;
color: red;
border: 2px solid;
} (a) width (b) font-style (c) 2px solid (d) border -
39.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 130px;
justify-content: flex-start;
}
Inside are 3 boxes, each 40px wide (no margins). - 40.🎯 What kind of selector is #main? (a) an id selector (b) an element selector (c) a class selector
Answer key
- 113
- .menu
- 50
- 250
- False
- False
- green
- #main
- the screen width
- color
- adds space around boxes
- text-align
- fits every screen
- <h2 class="note">
- 36
- CSS
- True
- center
- bold
- black
- HTML
- width
- 40
- 388
- .star
- sets colours and fonts
- the later one
- 10px
- margin
- lays out the page
- border
- 1
- gap
- 20
- 800px or wider
- centres a heading
- magenta
- border
- 10
- an id selector
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids