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.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 22px;
}
} (a) No (b) Yes -
2.⚖️ What colour is the text of this element?
<h2 class="menu" id="logo">Hi</h2>
CSS:
#logo { color: green; }
.menu { color: orange; }
h2 { color: red; } (a) black (b) green (c) red (d) orange -
3.⚖️ What colour is the text of this element?
<h2 class="box" id="top">Hi</h2>
CSS:
h2 { color: red; }
h2 { color: black; } (a) green (b) red (c) purple (d) black - 4.True or false: .menu is an id selector. (a) False (b) True
-
5.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
background-color: yellow;
font-style: italic;
} - 6.🔍 Which is the odd one out? (a) shows a pop-up message (b) counts down a timer (c) checks a quiz answer (d) makes a form box
- 7.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the viewport meta tag (c) the br tag (d) the hr tag
-
8.✍️ What value is given to border in this rule?
h2 {
border: 2px solid;
text-align: center;
padding: 8px;
} (a) border (b) 300px (c) italic (d) 2px solid - 9.🎯 Can many elements share the same class? (a) Yes (b) No
-
10.⚖️ What colour is the text of this element?
<h1 class="note" id="logo">Hi</h1>
CSS:
h1 { color: purple; }
.note { color: red; }
#logo { color: green; } (a) red (b) purple (c) yellow (d) green - 11.🌈 Which colour is #ffff00? (a) yellow (b) blue (c) bright green (d) red
- 12.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
- 13.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
- 14.True or false: JavaScript lays out the page. (a) True (b) False
-
15.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 330px;
justify-content: flex-end;
}
Inside are 3 boxes, each 100px wide (no margins). - 16.✍️ How does a CSS comment start? (a) /* (b) <!-- (c) # (d) //
-
17.🎯 Which CSS selector matches this element?
<div class="box" id="top">Hello</div> (a) .box (b) #box (c) #intro (d) .star - 18.What does color do? (a) colours behind the text (b) makes the text bold (c) sets the letter colour (d) centres a heading
- 19.True or false: li is an element selector. (a) True (b) False
- 20.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) blue (c) red (d) black
- 21.📦 In the box model, which part is the line round the box? (a) border (b) padding (c) margin (d) content
-
22.⚖️ What colour is the text of this element?
<h1 class="star" id="top">Hi</h1>
CSS:
#top { color: red; }
#top { color: blue; } (a) orange (b) green (c) blue (d) red -
23.🖌️ What colour is behind the letters?
h1 {
text-align: center;
font-size: 32px;
color: black;
background-color: green;
} (a) blue (b) green (c) black - 24.🖌️ Which CSS property colours behind the text? (a) font-size (b) font-family (c) font-weight (d) background-color
-
25.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 20px;
}
} (a) No (b) Yes -
26.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 14px;
}
} - 27.📱 max-width: 600px applies when the screen is ___. (a) 600px or narrower (b) 600px or wider (c) exactly 1000px (d) turned off
- 28.🖌️ Which CSS property makes letters bigger? (a) font-size (b) text-align (c) font-weight (d) background-color
- 29.🎯 What kind of selector is #main? (a) a class selector (b) an element selector (c) an id selector
- 30.🧩 Which language reacts to a button click? (a) HTML (b) JavaScript (c) CSS
- 31.🎯 What kind of selector is #top? (a) an id selector (b) an element selector (c) a class selector
-
32.🎯 Which CSS selector matches this element?
<span class="box" id="main">Hello</span> (a) .star (b) #box (c) .box (d) #logo - 33.True or false: the border is a solid or dotted edge. (a) False (b) True
- 34.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) turned off (c) 800px or wider (d) exactly 100px
-
35.✍️ Which property is set to 8px in this rule?
h2 {
font-size: 20px;
color: red;
margin: 10px;
padding: 8px;
} (a) 8px (b) font-weight (c) padding (d) border - 36.🌈 Which hex code is white? (a) #00ffff (b) #ffff00 (c) #ffffff (d) #0000ff
- 37.🎯 What kind of selector is .card? (a) an id selector (b) an element selector (c) a class selector
- 38.✍️ Which sign ends each CSS declaration? (a) : (b) ; (c) , (d) .
-
39.✍️ What value is given to font-size in this rule?
li {
font-size: 20px;
margin: 10px;
color: red;
} (a) center (b) 20px (c) font-size (d) yellow - 40.💪 Which flexbox property turns on flexbox? (a) gap (b) align-items (c) justify-content (d) display: flex
Answer key
- No
- green
- black
- False
- 2
- makes a form box
- the viewport meta tag
- 2px solid
- Yes
- green
- yellow
- an element selector
- an id selector
- False
- 30
- /*
- .box
- sets the letter colour
- True
- red
- border
- blue
- green
- background-color
- No
- 12
- 600px or narrower
- font-size
- an id selector
- JavaScript
- an id selector
- .box
- True
- 800px or wider
- padding
- #ffffff
- a class selector
- ;
- 20px
- display: flex
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids