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 CSS selector matches this element?
<span class="menu" id="main">Hello</span> (a) #logo (b) p (c) #menu (d) span - 2.🖌️ Which CSS property picks the font style? (a) font-weight (b) text-align (c) font-family (d) font-size
- 3.💪 Which justify-content value packs boxes at the start? (a) flex-end (b) space-between (c) flex-start (d) center
-
4.✍️ What value is given to border in this rule?
li {
margin: 10px;
border: 2px solid;
color: red;
} (a) italic (b) border (c) 300px (d) 2px solid - 5.Which of these does HTML do? (a) shows a pop-up message (b) counts down a timer (c) reacts to a button click (d) makes headings and lists
-
6.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 370px;
justify-content: flex-start;
}
Inside are 4 boxes, each 80px wide (no margins). - 7.🌈 In #0000c3 the blue part is the hex number c3. What is it as a normal number?
- 8.What does background-color do? (a) colours behind the text (b) sets the letter colour (c) makes letters bigger (d) makes the text bold
- 9.🖌️ Which CSS property sets the letter colour? (a) color (b) background-color (c) font-weight (d) font-size
-
10.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 320px;
justify-content: center;
}
Inside are 3 boxes, each 100px wide (no margins). - 11.🌈 In #rrggbb, which colour do the first two digits give? (a) red (b) blue (c) green (d) black
-
12.⚖️ What colour is the text of this element?
<p class="box" id="logo">Hi</p>
CSS:
p { color: red; }
.box { color: orange; } (a) blue (b) black (c) orange (d) red - 13.🔍 Which is the odd one out? (a) makes a link (b) sets colours and fonts (c) puts a picture on a page (d) makes headings and lists
-
14.✍️ How many declarations (property: value pairs) are in this rule?
body {
font-size: 20px;
background-color: yellow;
} - 15.🧩 Which language gives the page structure? (a) JavaScript (b) CSS (c) HTML
- 16.🧩 Which language puts a picture on a page? (a) JavaScript (b) HTML (c) CSS
-
17.✍️ What value is given to margin in this rule?
body {
font-size: 20px;
text-align: center;
margin: 10px;
} (a) 8px (b) margin (c) bold (d) 10px - 18.🖌️ Which CSS property centres a heading? (a) color (b) background-color (c) font-size (d) text-align
-
19.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} (a) No (b) Yes -
20.🖌️ Where does the text sit on its line?
li {
font-size: 28px;
color: white;
background-color: orange;
text-align: center;
} (a) in the middle (b) on the left (c) on the right - 21.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
-
22.✍️ What value is given to width in this rule?
body {
font-size: 20px;
background-color: yellow;
width: 300px;
border: 2px solid;
} (a) red (b) width (c) italic (d) 300px - 23.💪 Which flexbox property sets space between boxes? (a) flex-direction (b) justify-content (c) gap (d) display: flex
-
24.✍️ What value is given to font-size in this rule?
h2 {
font-size: 20px;
border: 2px solid;
margin: 10px;
} (a) 20px (b) center (c) yellow (d) font-size - 25.True or false: .card is an id selector. (a) False (b) True
- 26.✍️ In color: blue; which part is the property? (a) ; (b) blue (c) : (d) color
- 27.True or false: #top is an element selector. (a) True (b) False
- 28.True or false: HTML checks a quiz answer. (a) False (b) True
-
29.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 160px;
justify-content: space-between;
}
Inside are 2 boxes, each 60px wide (no margins). -
30.✍️ How many declarations (property: value pairs) are in this rule?
.note {
color: red;
} -
31.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 20px;
}
} - 32.Which of these does JavaScript do? (a) adds space around boxes (b) makes a form box (c) puts a picture on a page (d) counts down a timer
-
33.⚖️ What colour is the text of this element?
<p class="big" id="top">Hi</p>
CSS:
p { color: yellow; }
p { color: black; } (a) yellow (b) blue (c) red (d) black -
34.🖌️ What colour are the letters?
h1 {
background-color: blue;
font-size: 12px;
text-align: right;
color: green;
} (a) orange (b) blue (c) green -
35.🖌️ What colour is behind the letters?
h1 {
color: blue;
font-size: 32px;
background-color: green;
text-align: left;
} (a) blue (b) green (c) orange - 36.🎯 Which sign starts an id selector? (a) # (b) . (c) & (d) @
- 37.What does text-align do? (a) centres a heading (b) sets the letter colour (c) picks the font style (d) makes letters bigger
- 38.🌈 Which hex code is blue? (a) #0000ff (b) #ff0000 (c) #ffff00 (d) #000000
-
39.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 200px;
justify-content: center;
}
Inside are 2 boxes, each 80px wide (no margins). - 40.⚖️ Which selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
Answer key
- span
- font-family
- flex-start
- 2px solid
- makes headings and lists
- 50
- 195
- colours behind the text
- color
- 10
- red
- orange
- sets colours and fonts
- 2
- HTML
- HTML
- 10px
- text-align
- Yes
- in the middle
- an element selector
- 300px
- gap
- 20px
- False
- color
- False
- False
- 40
- 1
- 20
- counts down a timer
- black
- green
- green
- #
- centres a heading
- #0000ff
- 20
- an id selector
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids