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.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 490px;
justify-content: space-between;
}
Inside are 4 boxes, each 100px wide (no margins). -
2.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 250px;
justify-content: flex-start;
}
Inside are 4 boxes, each 50px wide (no margins). - 3.🎯 Which sign starts an id selector? (a) @ (b) . (c) # (d) &
-
4.🖌️ How big is the text, in px?
h2 {
text-align: left;
background-color: blue;
font-size: 20px;
color: purple;
} -
5.⚖️ What colour is the text of this element?
<p class="box" id="top">Hi</p>
CSS:
p { color: white; }
p { color: blue; } (a) blue (b) orange (c) black (d) white -
6.🎯 Which CSS selector matches this element?
<p class="box" id="intro">Hello</p> (a) #box (b) .star (c) .intro (d) p -
7.✍️ Which property is set to italic in this rule?
body {
margin: 10px;
font-style: italic;
} (a) italic (b) font-size (c) font-style (d) color - 8.✍️ Which sign goes between a property and its value? (a) = (b) ; (c) - (d) :
- 9.🖌️ Which CSS property picks the font style? (a) background-color (b) color (c) font-family (d) font-size
- 10.🔍 Which is the odd one out? (a) lays out the page (b) gives the page structure (c) puts a picture on a page (d) makes a form box
- 11.🎯 What kind of selector is #main? (a) an id selector (b) a class selector (c) an element selector
- 12.💪 Which justify-content value packs boxes at the end? (a) space-between (b) center (c) flex-start (d) flex-end
- 13.🌈 What is the biggest number one colour can have in rgb()? (a) 100 (b) 1000 (c) 99 (d) 255
-
14.🖌️ What colour is behind the letters?
h1 {
color: orange;
text-align: center;
background-color: purple;
font-size: 32px;
} (a) purple (b) orange (c) red - 15.🌈 Which colour is #0000ff? (a) blue (b) bright green (c) white (d) red
- 16.📱 Responsive design means a page ___. (a) has no pictures (b) is only for laptops (c) never changes (d) fits every screen
- 17.✍️ Which sign ends each CSS declaration? (a) : (b) . (c) ; (d) ,
- 18.What does background-color do? (a) makes the text bold (b) makes letters bigger (c) sets the letter colour (d) colours behind the text
-
19.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 120px;
padding: 30px;
border: 2px solid black;
margin: 5px;
} -
20.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 16px;
}
} - 21.🌈 Which colour is #000000? (a) cyan (b) magenta (c) black (d) red
- 22.✍️ In color: blue; which part is the value? (a) color (b) : (c) ; (d) blue
-
23.🎯 Which CSS selector matches this element?
<p class="big" id="main">Hello</p> (a) #main (b) #logo (c) .main (d) #big - 24.True or false: CSS changes the text size. (a) False (b) True
- 25.🧩 Which language makes a form box? (a) JavaScript (b) HTML (c) CSS
- 26.🧩 Which language makes a link? (a) JavaScript (b) CSS (c) HTML
- 27.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
-
28.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 1024px) {
p {
font-size: 26px;
}
} (a) Yes (b) No - 29.Which of these is padding? (a) a solid or dotted edge (b) space inside the border (c) the text or picture (d) space outside the border
- 30.True or false: .note is a class selector. (a) False (b) True
-
31.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 280px;
padding: 15px;
border: 2px solid black;
margin: 10px;
} -
32.✍️ What is the selector in this CSS rule?
li {
padding: 8px;
color: red;
font-weight: bold;
} (a) body (b) padding (c) li (d) red -
33.✍️ How many declarations (property: value pairs) are in this rule?
body {
font-style: italic;
} -
34.✍️ Which property is set to 20px in this rule?
body {
font-weight: bold;
font-size: 20px;
border: 2px solid;
} (a) font-size (b) text-align (c) 20px (d) background-color -
35.✍️ What value is given to text-align in this rule?
p {
padding: 8px;
text-align: center;
font-size: 20px;
} (a) center (b) yellow (c) text-align (d) 10px -
36.🖌️ Where does the text sit on its line?
li {
text-align: left;
background-color: green;
font-size: 36px;
color: yellow;
} (a) on the right (b) in the middle (c) on the left -
37.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 120px;
padding: 5px;
border: 2px solid black;
margin: 5px;
} - 38.📦 In the box model, which part is space inside the border? (a) margin (b) padding (c) content (d) border
-
39.🖌️ What colour is behind the letters?
h2 {
text-align: right;
font-size: 20px;
color: blue;
background-color: green;
} (a) yellow (b) blue (c) green -
40.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 150px;
padding: 25px;
border: 1px solid black;
margin: 15px;
}
Answer key
- 30
- 50
- #
- 20
- blue
- p
- font-style
- :
- font-family
- lays out the page
- an id selector
- flex-end
- 255
- purple
- blue
- fits every screen
- ;
- colours behind the text
- 194
- 16
- black
- blue
- #main
- True
- HTML
- HTML
- an element selector
- No
- space inside the border
- True
- 334
- li
- 1
- font-size
- center
- on the left
- 144
- padding
- green
- 202
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids