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.🎯 What kind of selector is #top? (a) an id selector (b) an element selector (c) a class selector
- 2.True or false: #end is an id selector. (a) True (b) False
-
3.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 80px;
padding: 15px;
border: 3px solid black;
margin: 20px;
} -
4.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 70px;
padding: 5px;
border: 3px solid black;
margin: 5px;
} -
5.⚖️ What colour is the text of this element?
<p class="menu" id="intro">Hi</p>
CSS:
#intro { color: black; }
#intro { color: white; } (a) white (b) blue (c) black (d) orange - 6.✍️ Which sign ends each CSS declaration? (a) . (b) ; (c) : (d) ,
- 7.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the viewport meta tag (c) the br tag (d) the title tag
- 8.🌈 Which colour is #0000ff? (a) black (b) red (c) magenta (d) blue
-
9.⚖️ What colour is the text of this element?
<h2 class="red" id="end">Hi</h2>
CSS:
.red { color: black; }
h2 { color: orange; } (a) red (b) white (c) orange (d) black -
10.🖌️ What colour are the letters?
h1 {
font-size: 12px;
background-color: red;
color: black;
text-align: right;
} (a) black (b) orange (c) red -
11.🎯 Which CSS selector matches this element?
<p class="big" id="hero">Hello</p> (a) #big (b) p (c) h1 (d) .hero -
12.✍️ What value is given to padding in this rule?
body {
width: 300px;
padding: 8px;
font-weight: bold;
font-style: italic;
} (a) 2px solid (b) bold (c) 8px (d) padding - 13.📱 What does a media query check? (a) the battery level (b) the time of day (c) the page title (d) the screen width
-
14.🎯 Which CSS selector matches this element?
<p class="box" id="logo">Hello</p> (a) .logo (b) .box (c) .star (d) #end -
15.🎯 Which CSS selector matches this element?
<li class="big" id="intro">Hello</li> (a) #main (b) li (c) #big (d) div -
16.🎯 Which CSS selector matches this element?
<h2 class="note" id="hero">Hello</h2> (a) .hero (b) .note (c) .big (d) #note - 17.True or false: li is a class selector. (a) False (b) True
- 18.🎯 What kind of selector is body? (a) an id selector (b) an element selector (c) a class selector
- 19.True or false: .card is an element selector. (a) True (b) False
-
20.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 340px;
justify-content: flex-start;
}
Inside are 3 boxes, each 100px wide (no margins). -
21.✍️ What value is given to font-size in this rule?
.note {
width: 300px;
font-size: 20px;
} (a) center (b) yellow (c) font-size (d) 20px -
22.⚖️ What colour is the text of this element?
<p class="red" id="hero">Hi</p>
CSS:
p { color: purple; }
.red { color: orange; } (a) yellow (b) orange (c) purple (d) white -
23.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 250px;
justify-content: center;
}
Inside are 3 boxes, each 50px wide (no margins). -
24.🎯 Which CSS selector matches this element?
<h1 class="big" id="hero">Hello</h1> (a) #top (b) h1 (c) .hero (d) #big -
25.🖌️ What colour is behind the letters?
h1 {
background-color: black;
text-align: center;
color: red;
font-size: 24px;
} (a) red (b) black (c) white -
26.🎯 Which CSS selector matches this element?
<p class="star" id="intro">Hello</p> (a) .intro (b) #main (c) .menu (d) #intro -
27.✍️ What value is given to border in this rule?
#top {
border: 2px solid;
font-weight: bold;
} (a) 300px (b) italic (c) 2px solid (d) border -
28.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 150px;
justify-content: flex-end;
}
Inside are 2 boxes, each 40px wide (no margins). -
29.⚖️ What colour is the text of this element?
<p class="box" id="main">Hi</p>
CSS:
.box { color: orange; }
p { color: yellow; }
#main { color: black; } (a) yellow (b) green (c) black (d) orange - 30.🎯 What kind of selector is .big? (a) an element selector (b) an id selector (c) a class selector
-
31.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 20px;
}
} - 32.🧩 Which language counts down a timer? (a) CSS (b) JavaScript (c) HTML
-
33.⚖️ What colour is the text of this element?
<h1 class="red" id="hero">Hi</h1>
CSS:
#hero { color: white; }
h1 { color: red; } (a) white (b) red (c) blue (d) orange -
34.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 480px) {
p {
font-size: 10px;
}
} -
35.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 230px;
padding: 15px;
border: 1px solid black;
margin: 0px;
} - 36.Which of these does HTML do? (a) makes a link (b) reacts to a button click (c) rounds box corners (d) checks a quiz answer
- 37.✍️ CSS declarations go inside which brackets? (a) ( ) (b) < > (c) [ ] (d) { }
-
38.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 26px;
}
} - 39.True or false: #hero is an id selector. (a) True (b) False
- 40.🎨 Which attribute adds CSS inside one tag? (a) href (b) alt (c) src (d) style
Answer key
- an id selector
- True
- 156
- 86
- white
- ;
- the viewport meta tag
- blue
- black
- black
- p
- 8px
- the screen width
- .box
- li
- .note
- False
- an element selector
- False
- 40
- 20px
- orange
- 50
- h1
- black
- #intro
- 2px solid
- 70
- black
- a class selector
- 24
- JavaScript
- white
- 16
- 262
- makes a link
- { }
- 26
- True
- style
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids