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.True or false: .star is an id selector. (a) False (b) True
-
2.⚖️ What colour is the text of this element?
<h1 class="note" id="logo">Hi</h1>
CSS:
h1 { color: purple; }
#logo { color: red; } (a) red (b) orange (c) purple (d) green -
3.✍️ What value is given to padding in this rule?
p {
font-size: 20px;
padding: 8px;
} (a) 8px (b) bold (c) 2px solid (d) padding - 4.📱 Responsive design means a page ___. (a) has no pictures (b) never changes (c) fits every screen (d) is only for laptops
-
5.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 100px;
padding: 25px;
border: 1px solid black;
margin: 0px;
} - 6.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) 600px or narrower (c) 600px or wider (d) exactly 1000px
- 7.Which of these does CSS do? (a) sets colours and fonts (b) shows a pop-up message (c) changes the page live (d) checks a quiz answer
- 8.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
- 9.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the first one (c) neither (d) the shorter one
- 10.True or false: CSS reacts to a button click. (a) False (b) True
- 11.🌈 Which colour is rgb(255, 255, 0)? (a) red (b) yellow (c) white (d) magenta
- 12.🧩 Which language reacts to a button click? (a) CSS (b) JavaScript (c) HTML
-
13.✍️ What is the selector in this CSS rule?
h2 {
color: red;
font-weight: bold;
background-color: yellow;
font-style: italic;
} (a) bold (b) h2 (c) color (d) h1 - 14.True or false: padding is space inside the border. (a) False (b) True
-
15.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 330px;
justify-content: space-between;
}
Inside are 4 boxes, each 60px wide (no margins). -
16.🖌️ Where does the text sit on its line?
h2 {
text-align: left;
background-color: black;
font-size: 36px;
color: orange;
} (a) on the left (b) on the right (c) in the middle - 17.🎯 What kind of selector is #top? (a) an id selector (b) an element selector (c) a class selector
- 18.Which of these does JavaScript do? (a) adds space around boxes (b) changes the page live (c) rounds box corners (d) sets colours and fonts
- 19.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) white (c) red (d) green
- 20.True or false: CSS rounds box corners. (a) False (b) True
-
21.🎯 Which CSS selector matches this element?
<span class="note" id="main">Hello</span> (a) #logo (b) .main (c) .note (d) .big -
22.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 16px;
}
} (a) Yes (b) No -
23.✍️ What is the selector in this CSS rule?
h2 {
padding: 8px;
font-weight: bold;
text-align: center;
width: 300px;
} (a) h2 (b) padding (c) bold (d) h1 - 24.🧩 Which language gives the page structure? (a) CSS (b) HTML (c) JavaScript
- 25.🔍 Which is the odd one out? (a) rounds box corners (b) checks a quiz answer (c) shows a pop-up message (d) reacts to a button click
- 26.True or false: margin is space outside the border. (a) False (b) True
-
27.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 6px;
}
} - 28.🌈 In #2a0000 the red part is the hex number 2a. What is it as a normal number?
-
29.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 24px;
}
} (a) No (b) Yes - 30.📱 What does a media query check? (a) the time of day (b) the page title (c) the screen width (d) the battery level
-
31.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 200px;
padding: 30px;
border: 5px solid black;
margin: 5px;
} -
32.⚖️ What colour is the text of this element?
<h2 class="big" id="main">Hi</h2>
CSS:
#main { color: black; }
.big { color: purple; }
h2 { color: orange; } (a) orange (b) green (c) purple (d) black -
33.✍️ What is the selector in this CSS rule?
.box {
font-style: italic;
background-color: yellow;
} (a) font-style (b) .box (c) yellow (d) h2 - 34.💪 Which flexbox property turns on flexbox? (a) justify-content (b) gap (c) flex-direction (d) display: flex
-
35.⚖️ What colour is the text of this element?
<p class="box" id="hero">Hi</p>
CSS:
#hero { color: purple; }
p { color: white; } (a) blue (b) white (c) purple (d) black - 36.Which of these does JavaScript do? (a) makes a link (b) rounds box corners (c) reacts to a button click (d) sets colours and fonts
- 37.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) exactly 100px (c) 800px or wider (d) turned off
-
38.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 180px;
justify-content: space-between;
}
Inside are 2 boxes, each 60px wide (no margins). - 39.🎯 Can many elements share the same class? (a) No (b) Yes
- 40.🧩 Which language shows a pop-up message? (a) CSS (b) HTML (c) JavaScript
Answer key
- False
- red
- 8px
- fits every screen
- 152
- 600px or narrower
- sets colours and fonts
- an id selector
- the later one
- False
- yellow
- JavaScript
- h2
- True
- 30
- on the left
- an id selector
- changes the page live
- blue
- True
- .note
- Yes
- h2
- HTML
- rounds box corners
- True
- 12
- 42
- Yes
- the screen width
- 280
- black
- .box
- display: flex
- purple
- reacts to a button click
- 800px or wider
- 60
- Yes
- JavaScript
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids