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.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 20px;
}
} -
2.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 90px;
padding: 10px;
border: 4px solid black;
margin: 10px;
} -
3.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 440px;
justify-content: center;
}
Inside are 3 boxes, each 100px wide (no margins). - 4.🎯 Which sign starts an id selector? (a) . (b) # (c) & (d) @
- 5.🎯 Which element does the selector p style? (a) <h1> (b) <p class="menu"> (c) <li id="end"> (d) <h2 class="menu">
- 6.🌈 Which colour is #ff0000? (a) cyan (b) yellow (c) red (d) bright green
-
7.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 16px;
}
} (a) No (b) Yes -
8.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 290px;
justify-content: space-between;
}
Inside are 4 boxes, each 50px wide (no margins). -
9.🖌️ How big is the text, in px?
p {
color: blue;
text-align: left;
background-color: green;
font-size: 24px;
} -
10.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 1024px) {
p {
font-size: 16px;
}
} -
11.🖌️ What colour is behind the letters?
li {
background-color: purple;
text-align: right;
font-size: 12px;
color: red;
} (a) red (b) green (c) purple - 12.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
- 13.What does font-family do? (a) colours behind the text (b) picks the font style (c) sets the letter colour (d) makes the text bold
-
14.✍️ Which property is set to 8px in this rule?
h1 {
border: 2px solid;
padding: 8px;
font-weight: bold;
text-align: center;
} (a) 8px (b) border (c) padding (d) font-weight - 15.🖌️ Which CSS property picks the font style? (a) font-family (b) font-weight (c) color (d) font-size
- 16.🧩 Which language rounds box corners? (a) JavaScript (b) CSS (c) HTML
-
17.⚖️ What colour is the text of this element?
<h1 class="star" id="end">Hi</h1>
CSS:
#end { color: black; }
#end { color: red; } (a) green (b) red (c) orange (d) black -
18.✍️ Which property is set to italic in this rule?
p {
color: red;
background-color: yellow;
font-style: italic;
} (a) font-size (b) font-style (c) italic (d) color - 19.🌈 Which colour of light is strongest in rgb(161, 108, 82)? (a) green (b) red (c) blue
- 20.🎯 Which element does the selector h1 style? (a) <h1 class="big"> (b) <li class="big"> (c) <div id="logo"> (d) <h2>
- 21.📦 In the box model, which part is space outside the border? (a) padding (b) content (c) border (d) margin
- 22.🌈 Which colour is rgb(255, 255, 255)? (a) magenta (b) cyan (c) white (d) yellow
-
23.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} - 24.✍️ How does a CSS comment start? (a) # (b) // (c) /* (d) <!--
- 25.💪 Which justify-content value equal gaps, none at ends? (a) flex-end (b) center (c) flex-start (d) space-between
-
26.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
border: 2px solid;
color: red;
} - 27.📦 In the box model, which part is the gap to other boxes? (a) margin (b) content (c) padding (d) border
-
28.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 210px;
justify-content: flex-end;
}
Inside are 4 boxes, each 40px wide (no margins). - 29.🧩 Which language adds space around boxes? (a) CSS (b) JavaScript (c) HTML
- 30.🌈 Which hex code is yellow? (a) #00ff00 (b) #ff0000 (c) #00ffff (d) #ffff00
-
31.✍️ What is the selector in this CSS rule?
.box {
font-style: italic;
font-size: 20px;
width: 300px;
text-align: center;
} (a) 20px (b) font-style (c) .box (d) h2 - 32.🎯 Which element does the selector #top style? (a) <h2 id="top"> (b) <h2 class="top"> (c) <li class="big"> (d) <h2 id="intro">
-
33.🖌️ What colour is behind the letters?
p {
font-size: 40px;
background-color: white;
text-align: right;
color: blue;
} (a) blue (b) orange (c) white -
34.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 80px;
padding: 15px;
border: 1px solid black;
margin: 5px;
} -
35.🖌️ What colour are the letters?
p {
color: white;
text-align: center;
background-color: black;
font-size: 40px;
} (a) purple (b) black (c) white -
36.✍️ How many declarations (property: value pairs) are in this rule?
p {
color: red;
text-align: center;
padding: 8px;
width: 300px;
} -
37.🎯 Which CSS selector matches this element?
<p class="menu" id="main">Hello</p> (a) .note (b) .menu (c) .main (d) #menu -
38.⚖️ What colour is the text of this element?
<p class="menu" id="end">Hi</p>
CSS:
#end { color: yellow; }
p { color: green; } (a) purple (b) green (c) white (d) yellow - 39.💪 Which flexbox property turns on flexbox? (a) justify-content (b) display: flex (c) flex-direction (d) align-items
- 40.🧩 Which language reacts to a button click? (a) CSS (b) HTML (c) JavaScript
Answer key
- 20
- 118
- 70
- #
- <p class="menu">
- red
- Yes
- 30
- 24
- 16
- purple
- an element selector
- picks the font style
- padding
- font-family
- CSS
- red
- font-style
- red
- <h1 class="big">
- margin
- white
- 10
- /*
- space-between
- 2
- margin
- 50
- CSS
- #ffff00
- .box
- <h2 id="top">
- white
- 122
- white
- 4
- .menu
- yellow
- display: flex
- JavaScript
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids