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: .menu is an element selector. (a) True (b) False
-
2.⚖️ What colour is the text of this element?
<h2 class="big" id="main">Hi</h2>
CSS:
h2 { color: red; }
h2 { color: green; } (a) red (b) yellow (c) black (d) green -
3.✍️ What value is given to font-weight in this rule?
p {
font-weight: bold;
width: 300px;
} (a) font-weight (b) 300px (c) bold (d) 2px solid - 4.🎯 Which element does the selector #top style? (a) <div class="top"> (b) <div id="intro"> (c) <span class="big"> (d) <div id="top">
-
5.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 120px;
padding: 10px;
border: 3px solid black;
margin: 5px;
} - 6.Which of these is the border? (a) the text or picture (b) the gap round content (c) the line round the box (d) space inside the border
- 7.🎯 How many elements on a page should have the same id? (a) 5 (b) 2 (c) 1 (d) any number
- 8.🌈 Which colour of light is strongest in rgb(211, 108, 138)? (a) green (b) red (c) blue
- 9.True or false: HTML sets colours and fonts. (a) False (b) True
-
10.🎯 Which CSS selector matches this element?
<h1 class="star" id="end">Hello</h1> (a) h2 (b) #hero (c) .star (d) .menu - 11.⚖️ Which selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
- 12.🎨 Which tag holds CSS inside the head? (a) <body> (b) <style> (c) <script> (d) <css>
-
13.🎯 Which CSS selector matches this element?
<span class="star" id="main">Hello</span> (a) .menu (b) p (c) #logo (d) #main - 14.What does text-align do? (a) makes the text bold (b) makes letters bigger (c) sets the letter colour (d) centres a heading
- 15.🔍 Which is the odd one out? (a) makes a link (b) changes the page live (c) makes headings and lists (d) makes a form box
-
16.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-size: 20px;
padding: 8px;
background-color: yellow;
} - 17.True or false: margin is space inside the border. (a) True (b) False
-
18.⚖️ What colour is the text of this element?
<h2 class="box" id="logo">Hi</h2>
CSS:
h2 { color: purple; }
.box { color: green; }
#logo { color: black; } (a) green (b) red (c) black (d) purple - 19.🎯 What kind of selector is #hero? (a) an id selector (b) an element selector (c) a class selector
- 20.📱 Responsive design means a page ___. (a) is only for laptops (b) never changes (c) has no pictures (d) fits every screen
-
21.✍️ How many declarations (property: value pairs) are in this rule?
.box {
font-style: italic;
} -
22.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 14px;
}
} (a) Yes (b) No - 23.✍️ How does a CSS comment start? (a) /* (b) // (c) # (d) <!--
- 24.🎨 One CSS file can style how many pages? (a) no pages (b) only one image (c) only one word (d) many pages
- 25.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the shorter one (c) the later one (d) neither
- 26.🔍 Which is the odd one out? (a) sets colours and fonts (b) lays out the page (c) adds space around boxes (d) shows a pop-up message
- 27.💪 Which flexbox property spaces boxes along a row? (a) align-items (b) gap (c) display: flex (d) justify-content
-
28.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 22px;
}
} (a) Yes (b) No -
29.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 150px;
justify-content: space-between;
}
Inside are 2 boxes, each 50px wide (no margins). -
30.⚖️ What colour is the text of this element?
<h1 class="red" id="end">Hi</h1>
CSS:
#end { color: green; }
h1 { color: orange; } (a) green (b) orange (c) black (d) red -
31.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 120px;
padding: 15px;
border: 5px solid black;
margin: 5px;
} - 32.📱 What does a media query check? (a) the battery level (b) the screen width (c) the page title (d) the time of day
-
33.⚖️ What colour is the text of this element?
<p class="box" id="hero">Hi</p>
CSS:
#hero { color: red; }
.box { color: blue; } (a) orange (b) green (c) red (d) blue -
34.🖌️ What colour is behind the letters?
p {
font-size: 16px;
text-align: center;
background-color: black;
color: green;
} (a) black (b) green (c) orange - 35.🎯 Which element does the selector #hero style? (a) <h1 id="hero"> (b) <h1 class="hero"> (c) <h1 id="top"> (d) <h2 class="red">
-
36.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
padding: 8px;
} -
37.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 24px;
}
} -
38.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 120px;
justify-content: flex-start;
}
Inside are 2 boxes, each 40px wide (no margins). - 39.🌈 Which colour of light is strongest in rgb(6, 252, 20)? (a) blue (b) red (c) green
- 40.🔍 Which is the odd one out? (a) makes a form box (b) sets colours and fonts (c) lays out the page (d) rounds box corners
Answer key
- False
- green
- bold
- <div id="top">
- 156
- the line round the box
- 1
- red
- False
- .star
- an id selector
- <style>
- #main
- centres a heading
- changes the page live
- 3
- False
- black
- an id selector
- fits every screen
- 1
- No
- /*
- many pages
- the later one
- shows a pop-up message
- justify-content
- Yes
- 50
- green
- 170
- the screen width
- red
- black
- <h1 id="hero">
- 1
- 24
- 40
- green
- makes a form box
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids