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 attribute adds CSS inside one tag? (a) style (b) href (c) alt (d) src
- 2.🔍 Which is the odd one out? (a) adds space around boxes (b) makes headings and lists (c) gives the page structure (d) puts a picture on a page
-
3.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 320px;
justify-content: center;
}
Inside are 2 boxes, each 100px wide (no margins). -
4.🖌️ What colour are the letters?
li {
color: white;
background-color: blue;
text-align: center;
font-size: 12px;
} (a) blue (b) white (c) red -
5.🎯 Which CSS selector matches this element?
<li class="red" id="intro">Hello</li> (a) .intro (b) #red (c) li (d) div - 6.🔍 Which is the odd one out? (a) reacts to a button click (b) shows a pop-up message (c) rounds box corners (d) changes the page live
-
7.✍️ What value is given to padding in this rule?
h1 {
color: red;
font-size: 20px;
font-weight: bold;
padding: 8px;
} (a) padding (b) 8px (c) 2px solid (d) bold - 8.🌈 Which hex code is black? (a) #000000 (b) #0000ff (c) #ff0000 (d) #00ffff
-
9.🎯 Which CSS selector matches this element?
<span class="star" id="hero">Hello</span> (a) .menu (b) .hero (c) #star (d) span - 10.What does background-color do? (a) makes the text bold (b) centres a heading (c) picks the font style (d) colours behind the text
- 11.What does justify-content: center do? (a) packs boxes at the end (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the start
- 12.True or false: HTML sets colours and fonts. (a) False (b) True
- 13.True or false: #top is an id selector. (a) True (b) False
- 14.📦 In the box model, which part is the text or picture? (a) border (b) margin (c) content (d) padding
-
15.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 20px;
}
} (a) No (b) Yes -
16.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 1024px) {
p {
font-size: 26px;
}
} - 17.🌈 What is the biggest number one colour can have in rgb()? (a) 1000 (b) 100 (c) 255 (d) 99
-
18.✍️ What value is given to width in this rule?
.note {
border: 2px solid;
width: 300px;
color: red;
padding: 8px;
} (a) 300px (b) red (c) italic (d) width -
19.⚖️ What colour is the text of this element?
<p class="box" id="main">Hi</p>
CSS:
p { color: red; }
#main { color: yellow; }
.box { color: purple; } (a) purple (b) blue (c) red (d) yellow - 20.📦 In the box model, which part is space outside the border? (a) padding (b) border (c) content (d) margin
- 21.📱 Responsive design means a page ___. (a) fits every screen (b) is only for laptops (c) has no pictures (d) never changes
-
22.🖌️ Where does the text sit on its line?
h2 {
font-size: 40px;
color: orange;
text-align: center;
background-color: blue;
} (a) on the left (b) in the middle (c) on the right - 23.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) 600px or narrower (c) 600px or wider (d) exactly 1000px
- 24.🎯 Which element does the selector .star style? (a) <div id="star"> (b) <div class="star"> (c) <div class="menu"> (d) <span class="note">
- 25.Which of these does HTML do? (a) changes the page live (b) puts a picture on a page (c) shows a pop-up message (d) lays out the page
- 26.🎯 Which element does the selector #top style? (a) <h1 id="top"> (b) <h2 class="menu"> (c) <h1 id="intro"> (d) <h1 class="top">
- 27.🔍 Which is the odd one out? (a) reacts to a button click (b) lays out the page (c) counts down a timer (d) checks a quiz answer
-
28.🖌️ What colour are the letters?
li {
background-color: yellow;
color: purple;
text-align: right;
font-size: 32px;
} (a) blue (b) purple (c) yellow - 29.✍️ CSS declarations go inside which brackets? (a) { } (b) ( ) (c) < > (d) [ ]
-
30.🖌️ What colour is behind the letters?
p {
background-color: purple;
color: green;
text-align: center;
font-size: 16px;
} (a) purple (b) green (c) black -
31.🖌️ What colour are the letters?
h1 {
background-color: red;
font-size: 24px;
color: yellow;
text-align: center;
} (a) red (b) yellow (c) green - 32.🖌️ Which CSS property sets the letter colour? (a) color (b) font-family (c) text-align (d) font-weight
-
33.🖌️ How big is the text, in px?
li {
text-align: center;
font-size: 16px;
color: blue;
background-color: green;
} - 34.Which of these is padding? (a) the gap round content (b) the text or picture (c) space outside the border (d) the gap to other boxes
-
35.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 1024px) {
p {
font-size: 18px;
}
} (a) No (b) Yes -
36.⚖️ What colour is the text of this element?
<p class="box" id="logo">Hi</p>
CSS:
.box { color: purple; }
p { color: red; } (a) yellow (b) red (c) blue (d) purple -
37.⚖️ What colour is the text of this element?
<h1 class="star" id="logo">Hi</h1>
CSS:
#logo { color: yellow; }
h1 { color: red; }
.star { color: purple; } (a) red (b) yellow (c) white (d) purple -
38.⚖️ What colour is the text of this element?
<h2 class="menu" id="top">Hi</h2>
CSS:
.menu { color: blue; }
.menu { color: black; } (a) red (b) orange (c) black (d) blue -
39.🎯 Which CSS selector matches this element?
<li class="star" id="main">Hello</li> (a) div (b) #logo (c) #main (d) #star -
40.✍️ What is the selector in this CSS rule?
li {
border: 2px solid;
margin: 10px;
padding: 8px;
font-size: 20px;
} (a) body (b) li (c) border (d) 10px
Answer key
- style
- adds space around boxes
- 60
- white
- li
- rounds box corners
- 8px
- #000000
- span
- colours behind the text
- puts boxes in the middle
- False
- True
- content
- Yes
- 20
- 255
- 300px
- yellow
- margin
- fits every screen
- in the middle
- 600px or narrower
- <div class="star">
- puts a picture on a page
- <h1 id="top">
- lays out the page
- purple
- { }
- purple
- yellow
- color
- 16
- the gap round content
- Yes
- purple
- yellow
- black
- #main
- li
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids