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 value is given to margin in this rule?
p {
margin: 10px;
color: red;
} (a) 8px (b) margin (c) bold (d) 10px -
2.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 22px;
}
} - 3.True or false: JavaScript adds space around boxes. (a) True (b) False
- 4.🧩 Which language checks a quiz answer? (a) JavaScript (b) HTML (c) CSS
-
5.🎯 Which CSS selector matches this element?
<h2 class="big" id="logo">Hello</h2> (a) li (b) .red (c) #end (d) #logo - 6.💪 Which justify-content value equal gaps, none at ends? (a) center (b) space-between (c) flex-end (d) flex-start
- 7.What does justify-content: flex-start do? (a) packs boxes at the start (b) packs boxes at the end (c) puts boxes in the middle (d) equal gaps, none at ends
-
8.🎯 Which CSS selector matches this element?
<h1 class="box" id="top">Hello</h1> (a) .box (b) #box (c) .top (d) .star - 9.✍️ Which sign goes between a property and its value? (a) = (b) : (c) - (d) ;
- 10.🎯 Which element does the selector span style? (a) <h2 id="end"> (b) <p> (c) <h1 class="menu"> (d) <span class="menu">
- 11.What does color do? (a) makes the text bold (b) sets the letter colour (c) colours behind the text (d) picks the font style
-
12.🖌️ What colour are the letters?
p {
text-align: center;
font-size: 20px;
color: blue;
background-color: white;
} (a) blue (b) white (c) green - 13.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 3 (b) 4 (c) 2 (d) 6
-
14.🖌️ How big is the text, in px?
p {
color: blue;
text-align: left;
background-color: green;
font-size: 28px;
} -
15.🖌️ How big is the text, in px?
h2 {
text-align: right;
background-color: yellow;
font-size: 16px;
color: purple;
} - 16.🎯 What kind of selector is .big? (a) an id selector (b) an element selector (c) a class selector
- 17.🎯 Can many elements share the same class? (a) No (b) Yes
-
18.🖌️ What colour is behind the letters?
h2 {
font-size: 16px;
background-color: blue;
color: black;
text-align: left;
} (a) black (b) blue (c) white - 19.🌈 Which colour is #00ff00? (a) red (b) bright green (c) yellow (d) black
-
20.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 270px;
padding: 25px;
border: 1px solid black;
margin: 20px;
} - 21.Which of these does HTML do? (a) makes a form box (b) counts down a timer (c) sets colours and fonts (d) checks a quiz answer
- 22.What does justify-content: space-between do? (a) packs boxes at the start (b) packs boxes at the end (c) puts boxes in the middle (d) equal gaps, none at ends
-
23.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 22px;
}
} - 24.What does background-color do? (a) sets the letter colour (b) makes the text bold (c) colours behind the text (d) makes letters bigger
-
25.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 30px;
}
} (a) Yes (b) No - 26.True or false: JavaScript gives the page structure. (a) True (b) False
- 27.🌈 In #00a600 the green part is the hex number a6. What is it as a normal number?
-
28.⚖️ What colour is the text of this element?
<p class="box" id="intro">Hi</p>
CSS:
p { color: orange; }
p { color: purple; } (a) white (b) purple (c) orange (d) blue -
29.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 140px;
padding: 10px;
border: 3px solid black;
margin: 10px;
} -
30.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 22px;
}
} -
31.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 260px;
justify-content: space-between;
}
Inside are 3 boxes, each 60px wide (no margins). -
32.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
text-align: center;
color: red;
font-style: italic;
font-size: 20px;
} - 33.🧩 Which language makes a link? (a) HTML (b) CSS (c) JavaScript
-
34.🖌️ What colour is behind the letters?
li {
text-align: right;
font-size: 20px;
background-color: yellow;
color: green;
} (a) green (b) yellow (c) orange -
35.🎯 Which CSS selector matches this element?
<h1 class="note" id="top">Hello</h1> (a) #note (b) #intro (c) h1 (d) .big -
36.🎯 Which CSS selector matches this element?
<h2 class="star" id="main">Hello</h2> (a) li (b) .main (c) h2 (d) #star - 37.What does justify-content: center do? (a) packs boxes at the start (b) packs boxes at the end (c) equal gaps, none at ends (d) puts boxes in the middle
-
38.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 220px;
justify-content: flex-start;
}
Inside are 4 boxes, each 50px wide (no margins). -
39.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 210px;
justify-content: space-between;
}
Inside are 2 boxes, each 100px wide (no margins). -
40.✍️ Which property is set to bold in this rule?
#top {
font-style: italic;
background-color: yellow;
font-weight: bold;
width: 300px;
} (a) font-weight (b) border (c) bold (d) width
Answer key
- 10px
- 22
- False
- JavaScript
- #logo
- space-between
- packs boxes at the start
- .box
- :
- <span class="menu">
- sets the letter colour
- blue
- 3
- 28
- 16
- a class selector
- Yes
- blue
- bright green
- 362
- makes a form box
- equal gaps, none at ends
- 22
- colours behind the text
- No
- False
- 166
- purple
- 186
- 16
- 40
- 4
- HTML
- yellow
- h1
- h2
- puts boxes in the middle
- 20
- 10
- font-weight
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids