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.🖌️ Where does the text sit on its line?
h1 {
text-align: left;
color: blue;
background-color: orange;
font-size: 36px;
} (a) in the middle (b) on the left (c) on the right -
2.✍️ How many declarations (property: value pairs) are in this rule?
.note {
font-size: 20px;
border: 2px solid;
font-style: italic;
} - 3.True or false: #end is an id selector. (a) False (b) True
- 4.Which of these does HTML do? (a) changes the page live (b) checks a quiz answer (c) lays out the page (d) makes headings and lists
-
5.⚖️ What colour is the text of this element?
<h2 class="big" id="top">Hi</h2>
CSS:
.big { color: yellow; }
.big { color: orange; } (a) orange (b) red (c) yellow (d) black -
6.⚖️ What colour is the text of this element?
<h2 class="note" id="intro">Hi</h2>
CSS:
h2 { color: black; }
#intro { color: yellow; } (a) blue (b) yellow (c) black (d) green -
7.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 90px;
padding: 30px;
border: 5px solid black;
margin: 15px;
} -
8.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 420px;
justify-content: space-between;
}
Inside are 3 boxes, each 100px wide (no margins). -
9.✍️ What value is given to margin in this rule?
h1 {
margin: 10px;
font-style: italic;
color: red;
background-color: yellow;
} (a) 10px (b) bold (c) 8px (d) margin - 10.🧩 Which language gives the page structure? (a) JavaScript (b) CSS (c) HTML
- 11.📱 What does a media query check? (a) the time of day (b) the page title (c) the screen width (d) the battery level
- 12.🌈 Which colour is #00ff00? (a) red (b) cyan (c) black (d) bright green
- 13.🎯 Which element does the selector #end style? (a) <span id="end"> (b) <p class="star"> (c) <span class="end"> (d) <span id="hero">
-
14.⚖️ What colour is the text of this element?
<p class="red" id="top">Hi</p>
CSS:
p { color: green; }
p { color: purple; } (a) blue (b) purple (c) green (d) white - 15.🎯 How many elements on a page should have the same id? (a) 5 (b) any number (c) 2 (d) 1
-
16.⚖️ What colour is the text of this element?
<p class="box" id="end">Hi</p>
CSS:
p { color: white; }
.box { color: red; } (a) red (b) white (c) orange (d) purple -
17.💪 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 50px wide (no margins). -
18.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 140px;
justify-content: center;
}
Inside are 2 boxes, each 40px wide (no margins). - 19.🌈 Which hex code is blue? (a) #000000 (b) #0000ff (c) #ff00ff (d) #ffff00
-
20.⚖️ What colour is the text of this element?
<h2 class="note" id="main">Hi</h2>
CSS:
.note { color: black; }
#main { color: white; }
h2 { color: orange; } (a) white (b) black (c) orange (d) yellow -
21.✍️ How many declarations (property: value pairs) are in this rule?
li {
padding: 8px;
border: 2px solid;
font-weight: bold;
font-style: italic;
} -
22.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 190px;
padding: 20px;
border: 1px solid black;
margin: 20px;
} -
23.🎯 Which CSS selector matches this element?
<span class="star" id="hero">Hello</span> (a) #hero (b) #top (c) #star (d) p -
24.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 1024px) {
p {
font-size: 16px;
}
} - 25.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) turned off (c) 600px or narrower (d) exactly 1000px
- 26.🌈 In #rrggbb, which colour do the first two digits give? (a) red (b) green (c) black (d) blue
- 27.📦 In the box model, which part is the gap to other boxes? (a) border (b) content (c) padding (d) margin
-
28.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 16px;
}
} - 29.✍️ Which sign goes between a property and its value? (a) ; (b) = (c) - (d) :
-
30.✍️ How many declarations (property: value pairs) are in this rule?
body {
border: 2px solid;
margin: 10px;
padding: 8px;
} -
31.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 18px;
}
} (a) No (b) Yes -
32.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 110px;
padding: 25px;
border: 5px solid black;
margin: 5px;
} - 33.🎯 What kind of selector is #top? (a) an element selector (b) an id selector (c) a class selector
- 34.🔍 Which is the odd one out? (a) makes a link (b) makes headings and lists (c) puts a picture on a page (d) shows a pop-up message
-
35.🎯 Which CSS selector matches this element?
<h2 class="box" id="top">Hello</h2> (a) li (b) .star (c) #intro (d) h2 - 36.🖌️ Which CSS property makes the text bold? (a) font-size (b) font-weight (c) text-align (d) font-family
- 37.What does font-weight do? (a) makes the text bold (b) picks the font style (c) sets the letter colour (d) makes letters bigger
-
38.⚖️ What colour is the text of this element?
<h2 class="box" id="end">Hi</h2>
CSS:
h2 { color: black; }
h2 { color: purple; } (a) purple (b) blue (c) green (d) black - 39.✍️ How does a CSS comment start? (a) <!-- (b) /* (c) # (d) //
-
40.📱 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;
}
}
Answer key
- on the left
- 3
- True
- makes headings and lists
- orange
- yellow
- 190
- 60
- 10px
- HTML
- the screen width
- bright green
- <span id="end">
- purple
- 1
- red
- 20
- 30
- #0000ff
- white
- 4
- 272
- #hero
- 20
- 600px or narrower
- red
- margin
- 20
- :
- 3
- No
- 170
- an id selector
- shows a pop-up message
- h2
- font-weight
- makes the text bold
- purple
- /*
- 24
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids