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.🖌️ How big is the text, in px?
h2 {
text-align: center;
background-color: white;
font-size: 28px;
color: purple;
} -
2.✍️ What is the selector in this CSS rule?
h1 {
border: 2px solid;
font-size: 20px;
font-weight: bold;
text-align: center;
} (a) 20px (b) p (c) border (d) h1 -
3.✍️ What value is given to font-weight in this rule?
h1 {
font-weight: bold;
color: red;
} (a) font-weight (b) 300px (c) 2px solid (d) bold - 4.🧩 Which language rounds box corners? (a) JavaScript (b) HTML (c) CSS
- 5.✍️ CSS declarations go inside which brackets? (a) { } (b) [ ] (c) < > (d) ( )
- 6.🔍 Which is the odd one out? (a) makes a form box (b) makes headings and lists (c) changes the text size (d) puts a picture on a page
- 7.🎯 Can many elements share the same class? (a) No (b) Yes
-
8.⚖️ What colour is the text of this element?
<h1 class="menu" id="intro">Hi</h1>
CSS:
h1 { color: green; }
#intro { color: orange; }
.menu { color: red; } (a) purple (b) orange (c) red (d) green - 9.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 6 (b) 3 (c) 4 (d) 2
- 10.What does background-color do? (a) sets the letter colour (b) picks the font style (c) colours behind the text (d) makes letters bigger
- 11.🌈 Which hex code is blue? (a) #ffff00 (b) #0000ff (c) #ff0000 (d) #00ffff
-
12.✍️ What value is given to margin in this rule?
#top {
background-color: yellow;
margin: 10px;
text-align: center;
} (a) 8px (b) bold (c) 10px (d) margin -
13.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} (a) Yes (b) No -
14.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 180px;
justify-content: flex-end;
}
Inside are 3 boxes, each 50px wide (no margins). -
15.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 24px;
}
} (a) No (b) Yes -
16.🖌️ Where does the text sit on its line?
h1 {
background-color: white;
text-align: center;
font-size: 12px;
color: red;
} (a) on the left (b) on the right (c) in the middle -
17.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 10px;
}
} - 18.🌈 Which hex code is red? (a) #000000 (b) #ff0000 (c) #ffffff (d) #ffff00
-
19.✍️ How many declarations (property: value pairs) are in this rule?
p {
color: red;
font-style: italic;
width: 300px;
background-color: yellow;
} - 20.True or false: the border is a solid or dotted edge. (a) False (b) True
- 21.✍️ Which sign ends each CSS declaration? (a) , (b) : (c) . (d) ;
-
22.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 280px;
padding: 5px;
border: 2px solid black;
margin: 10px;
} - 23.🎯 Which element does the selector .red style? (a) <div id="red"> (b) <div class="box"> (c) <span class="star"> (d) <div class="red">
- 24.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) 600px or wider (c) exactly 1000px (d) 600px or narrower
-
25.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 200px;
padding: 10px;
border: 2px solid black;
margin: 20px;
} -
26.⚖️ What colour is the text of this element?
<h1 class="menu" id="intro">Hi</h1>
CSS:
h1 { color: orange; }
h1 { color: white; } (a) yellow (b) orange (c) white (d) black - 27.Which of these does CSS do? (a) reacts to a button click (b) checks a quiz answer (c) adds space around boxes (d) shows a pop-up message
- 28.Which of these does CSS do? (a) makes headings and lists (b) shows a pop-up message (c) makes a form box (d) changes the text size
- 29.✍️ Which sign goes between a property and its value? (a) : (b) ; (c) = (d) -
- 30.🧩 Which language shows a pop-up message? (a) JavaScript (b) HTML (c) CSS
-
31.⚖️ What colour is the text of this element?
<p class="star" id="hero">Hi</p>
CSS:
.star { color: orange; }
.star { color: blue; } (a) red (b) blue (c) orange (d) purple -
32.🎯 Which CSS selector matches this element?
<li class="star" id="main">Hello</li> (a) div (b) li (c) .menu (d) #logo - 33.🎯 What kind of selector is #top? (a) a class selector (b) an id selector (c) an element selector
-
34.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 600px) {
p {
font-size: 26px;
}
} (a) Yes (b) No -
35.✍️ What value is given to font-style in this rule?
h2 {
font-style: italic;
width: 300px;
margin: 10px;
} (a) font-style (b) italic (c) red (d) 20px - 36.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
-
37.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 320px;
justify-content: flex-start;
}
Inside are 3 boxes, each 80px wide (no margins). - 38.True or false: margin is the gap to other boxes. (a) True (b) False
-
39.✍️ What value is given to padding in this rule?
h1 {
padding: 8px;
font-style: italic;
margin: 10px;
} (a) 2px solid (b) bold (c) 8px (d) padding - 40.🎯 What kind of selector is .note? (a) a class selector (b) an id selector (c) an element selector
Answer key
- 28
- h1
- bold
- CSS
- { }
- changes the text size
- Yes
- orange
- 3
- colours behind the text
- #0000ff
- 10px
- No
- 30
- No
- in the middle
- 12
- #ff0000
- 4
- True
- ;
- 314
- <div class="red">
- 600px or narrower
- 264
- white
- adds space around boxes
- changes the text size
- :
- JavaScript
- blue
- li
- an id selector
- No
- italic
- an element selector
- 80
- True
- 8px
- a class selector
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids