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.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
-
2.✍️ Which property is set to red in this rule?
p {
margin: 10px;
color: red;
text-align: center;
background-color: yellow;
} (a) font-size (b) color (c) red (d) text-align -
3.✍️ What value is given to border in this rule?
.box {
padding: 8px;
font-style: italic;
border: 2px solid;
} (a) 2px solid (b) italic (c) border (d) 300px -
4.✍️ What value is given to padding in this rule?
.note {
padding: 8px;
border: 2px solid;
text-align: center;
} (a) 8px (b) 2px solid (c) padding (d) bold - 5.✍️ Which sign goes between a property and its value? (a) : (b) = (c) ; (d) -
-
6.🖌️ Where does the text sit on its line?
h2 {
font-size: 24px;
background-color: white;
color: black;
text-align: right;
} (a) on the left (b) on the right (c) in the middle -
7.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 32px;
}
} (a) Yes (b) No -
8.⚖️ What colour is the text of this element?
<h1 class="note" id="end">Hi</h1>
CSS:
.note { color: white; }
.note { color: purple; } (a) purple (b) green (c) orange (d) white -
9.🖌️ Where does the text sit on its line?
li {
text-align: right;
color: red;
font-size: 20px;
background-color: white;
} (a) on the left (b) in the middle (c) on the right - 10.✍️ How does a CSS comment start? (a) /* (b) # (c) // (d) <!--
-
11.✍️ Which property is set to italic in this rule?
.box {
border: 2px solid;
font-style: italic;
text-align: center;
} (a) color (b) font-style (c) italic (d) font-size - 12.💪 Which flexbox property spaces boxes along a row? (a) align-items (b) flex-direction (c) display: flex (d) justify-content
- 13.Which of these does HTML do? (a) changes the text size (b) adds space around boxes (c) rounds box corners (d) makes a form box
- 14.True or false: margin is space inside the border. (a) True (b) False
- 15.What does justify-content: flex-end do? (a) packs boxes at the end (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the start
- 16.🖌️ Which CSS property colours behind the text? (a) text-align (b) font-size (c) background-color (d) color
- 17.🎯 What kind of selector is .big? (a) a class selector (b) an element selector (c) an id selector
-
18.✍️ How many declarations (property: value pairs) are in this rule?
.note {
background-color: yellow;
width: 300px;
color: red;
font-style: italic;
} - 19.True or false: padding is space inside the border. (a) True (b) False
- 20.💪 Which flexbox property turns on flexbox? (a) gap (b) justify-content (c) align-items (d) display: flex
-
21.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 180px;
padding: 20px;
border: 5px solid black;
margin: 5px;
} -
22.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 20px;
}
} (a) No (b) Yes - 23.🌈 Which colour is rgb(255, 255, 255)? (a) blue (b) white (c) magenta (d) black
- 24.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) 600px or wider (c) exactly 1000px (d) 600px or narrower
- 25.True or false: the border is the gap round content. (a) False (b) True
- 26.🌈 Which colour is #ffff00? (a) red (b) magenta (c) yellow (d) cyan
- 27.🔍 Which is the odd one out? (a) lays out the page (b) reacts to a button click (c) checks a quiz answer (d) shows a pop-up message
- 28.True or false: CSS reacts to a button click. (a) True (b) False
-
29.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 180px;
padding: 15px;
border: 5px solid black;
margin: 5px;
} - 30.True or false: CSS counts down a timer. (a) True (b) False
-
31.🖌️ How big is the text, in px?
h1 {
font-size: 32px;
color: green;
text-align: right;
background-color: purple;
} - 32.Which of these does CSS do? (a) gives the page structure (b) makes a link (c) adds space around boxes (d) makes headings and lists
- 33.🧩 Which language gives the page structure? (a) CSS (b) JavaScript (c) HTML
- 34.True or false: .menu is an element selector. (a) True (b) False
-
35.✍️ What value is given to font-size in this rule?
h2 {
padding: 8px;
font-size: 20px;
} (a) center (b) 20px (c) font-size (d) yellow -
36.⚖️ What colour is the text of this element?
<p class="red" id="intro">Hi</p>
CSS:
#intro { color: purple; }
.red { color: red; }
p { color: white; } (a) purple (b) white (c) black (d) red - 37.🌈 In #rrggbb, which colour do the last two digits give? (a) white (b) red (c) blue (d) green
- 38.🔍 Which is the odd one out? (a) changes the page live (b) makes headings and lists (c) checks a quiz answer (d) counts down a timer
-
39.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 120px;
padding: 20px;
border: 3px solid black;
margin: 15px;
} -
40.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 240px;
justify-content: space-between;
}
Inside are 3 boxes, each 60px wide (no margins).
Answer key
- an id selector
- color
- 2px solid
- 8px
- :
- on the right
- Yes
- purple
- on the right
- /*
- font-style
- justify-content
- makes a form box
- False
- packs boxes at the end
- background-color
- a class selector
- 4
- True
- display: flex
- 240
- Yes
- white
- 600px or narrower
- False
- yellow
- lays out the page
- False
- 230
- False
- 32
- adds space around boxes
- HTML
- False
- 20px
- purple
- blue
- makes headings and lists
- 166
- 30
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids