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.🎯 Can many elements share the same class? (a) Yes (b) No
-
2.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 12px;
}
} (a) Yes (b) No -
3.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 20px;
}
} - 4.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
- 5.✍️ How does a CSS comment start? (a) // (b) <!-- (c) # (d) /*
-
6.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 380px;
justify-content: flex-start;
}
Inside are 4 boxes, each 80px wide (no margins). -
7.✍️ How many declarations (property: value pairs) are in this rule?
.box {
color: red;
border: 2px solid;
} -
8.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 80px;
padding: 5px;
border: 3px solid black;
margin: 5px;
} - 9.🎨 One CSS file can style how many pages? (a) no pages (b) only one word (c) many pages (d) only one image
- 10.🎯 What kind of selector is li? (a) an id selector (b) a class selector (c) an element selector
-
11.✍️ How many declarations (property: value pairs) are in this rule?
body {
width: 300px;
color: red;
font-style: italic;
} - 12.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the shorter one (c) neither (d) the later one
-
13.⚖️ What colour is the text of this element?
<h1 class="red" id="intro">Hi</h1>
CSS:
#intro { color: blue; }
#intro { color: black; } (a) orange (b) black (c) blue (d) purple - 14.True or false: HTML makes a link. (a) False (b) True
-
15.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 190px;
justify-content: flex-end;
}
Inside are 2 boxes, each 80px wide (no margins). -
16.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 250px;
justify-content: flex-end;
}
Inside are 3 boxes, each 80px wide (no margins). - 17.🎯 Which element does the selector p style? (a) <h2 class="big"> (b) <li id="intro"> (c) <p class="big"> (d) <h1>
- 18.What does justify-content: flex-end do? (a) packs boxes at the end (b) equal gaps, none at ends (c) puts boxes in the middle (d) packs boxes at the start
- 19.🎯 Which element does the selector p style? (a) <li id="logo"> (b) <h2 class="box"> (c) <p class="box"> (d) <h1>
-
20.✍️ What value is given to width in this rule?
li {
width: 300px;
background-color: yellow;
border: 2px solid;
margin: 10px;
} (a) red (b) width (c) italic (d) 300px -
21.⚖️ What colour is the text of this element?
<p class="big" id="end">Hi</p>
CSS:
.big { color: purple; }
.big { color: blue; } (a) orange (b) blue (c) purple (d) white - 22.🔍 Which is the odd one out? (a) shows a pop-up message (b) rounds box corners (c) lays out the page (d) sets colours and fonts
-
23.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 14px;
}
} (a) No (b) Yes - 24.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or wider (c) turned off (d) 600px or narrower
-
25.🖌️ How big is the text, in px?
p {
color: red;
text-align: left;
font-size: 12px;
background-color: blue;
} - 26.🧩 Which language reacts to a button click? (a) JavaScript (b) CSS (c) HTML
- 27.True or false: CSS puts a picture on a page. (a) False (b) True
-
28.🎯 Which CSS selector matches this element?
<li class="box" id="main">Hello</li> (a) li (b) .star (c) #box (d) .main -
29.✍️ Which property is set to 20px in this rule?
body {
font-size: 20px;
text-align: center;
} (a) text-align (b) background-color (c) 20px (d) font-size - 30.🎯 Which sign starts an id selector? (a) # (b) & (c) @ (d) .
-
31.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 4 boxes, each 50px wide (no margins). - 32.What does color do? (a) sets the letter colour (b) makes the text bold (c) makes letters bigger (d) centres a heading
-
33.🖌️ What colour is behind the letters?
h1 {
font-size: 24px;
text-align: left;
background-color: blue;
color: orange;
} (a) blue (b) orange (c) green -
34.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 16px;
}
} - 35.📱 What does a media query check? (a) the battery level (b) the page title (c) the time of day (d) the screen width
- 36.📱 Responsive design means a page ___. (a) is only for laptops (b) never changes (c) fits every screen (d) has no pictures
-
37.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 210px;
justify-content: flex-start;
}
Inside are 3 boxes, each 50px wide (no margins). - 38.Which of these does HTML do? (a) adds space around boxes (b) lays out the page (c) shows a pop-up message (d) gives the page structure
- 39.Which of these does CSS do? (a) shows a pop-up message (b) gives the page structure (c) counts down a timer (d) adds space around boxes
- 40.🎨 Which tag connects an outside CSS file? (a) <link> (b) <css> (c) <img> (d) <a>
Answer key
- Yes
- Yes
- 20
- an id selector
- /*
- 60
- 2
- 96
- many pages
- an element selector
- 3
- the later one
- black
- True
- 30
- 10
- <p class="big">
- packs boxes at the end
- <p class="box">
- 300px
- blue
- shows a pop-up message
- Yes
- 600px or narrower
- 12
- JavaScript
- False
- li
- font-size
- #
- 30
- sets the letter colour
- blue
- 16
- the screen width
- fits every screen
- 60
- gives the page structure
- adds space around boxes
- <link>
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids