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 CSS property centres a heading? (a) text-align (b) font-weight (c) background-color (d) color
-
2.✍️ What value is given to padding in this rule?
h2 {
padding: 8px;
background-color: yellow;
font-size: 20px;
text-align: center;
} (a) padding (b) bold (c) 2px solid (d) 8px - 3.🎯 Which element does the selector #logo style? (a) <div class="logo"> (b) <div id="logo"> (c) <div id="end"> (d) <span class="box">
-
4.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 16px;
}
} -
5.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 240px;
justify-content: flex-start;
}
Inside are 2 boxes, each 100px wide (no margins). -
6.⚖️ What colour is the text of this element?
<h1 class="box" id="top">Hi</h1>
CSS:
h1 { color: red; }
h1 { color: green; } (a) green (b) blue (c) red (d) black -
7.✍️ What value is given to color in this rule?
p {
margin: 10px;
background-color: yellow;
color: red;
} (a) center (b) color (c) 20px (d) red - 8.💪 Which justify-content value packs boxes at the start? (a) space-between (b) flex-start (c) center (d) flex-end
-
9.🖌️ What colour is behind the letters?
h1 {
text-align: center;
background-color: black;
color: red;
font-size: 24px;
} (a) black (b) red (c) yellow -
10.🖌️ What colour are the letters?
li {
font-size: 12px;
text-align: left;
background-color: green;
color: black;
} (a) green (b) black (c) yellow -
11.🎯 Which CSS selector matches this element?
<h2 class="red" id="main">Hello</h2> (a) .main (b) #logo (c) #main (d) #red - 12.🌈 Which colour is rgb(0, 255, 255)? (a) white (b) cyan (c) yellow (d) magenta
- 13.🎨 Which tag connects an outside CSS file? (a) <link> (b) <css> (c) <a> (d) <img>
-
14.✍️ What value is given to color in this rule?
body {
font-size: 20px;
color: red;
font-weight: bold;
} (a) 20px (b) center (c) red (d) color - 15.True or false: the border is the gap to other boxes. (a) False (b) True
- 16.True or false: JavaScript checks a quiz answer. (a) True (b) False
-
17.🖌️ What colour are the letters?
p {
text-align: right;
background-color: purple;
color: white;
font-size: 28px;
} (a) purple (b) white (c) red - 18.🎯 Which element does the selector #logo style? (a) <div class="box"> (b) <li id="logo"> (c) <li class="logo"> (d) <li id="end">
-
19.🖌️ How big is the text, in px?
h2 {
text-align: left;
color: black;
background-color: green;
font-size: 20px;
} -
20.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
background-color: yellow;
width: 300px;
font-weight: bold;
font-size: 20px;
} - 21.🌈 Which colour is #ff00ff? (a) red (b) yellow (c) blue (d) magenta
- 22.What does background-color do? (a) sets the letter colour (b) colours behind the text (c) makes letters bigger (d) centres a heading
- 23.✍️ CSS declarations go inside which brackets? (a) ( ) (b) [ ] (c) < > (d) { }
- 24.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
- 25.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
- 26.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) justify-content (c) display: flex (d) gap
- 27.🧩 Which language rounds box corners? (a) JavaScript (b) CSS (c) HTML
-
28.🎯 Which CSS selector matches this element?
<div class="note" id="logo">Hello</div> (a) #logo (b) .big (c) #note (d) .logo - 29.Which of these is margin? (a) the line round the box (b) the gap round content (c) a solid or dotted edge (d) space outside the border
- 30.🧩 Which language gives the page structure? (a) JavaScript (b) CSS (c) HTML
- 31.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) green (c) blue (d) white
- 32.🎯 Which element does the selector .note style? (a) <li class="big"> (b) <li id="note"> (c) <li class="note"> (d) <div class="red">
-
33.⚖️ What colour is the text of this element?
<p class="star" id="logo">Hi</p>
CSS:
p { color: orange; }
p { color: red; } (a) orange (b) red (c) white (d) blue -
34.✍️ What is the selector in this CSS rule?
.box {
font-size: 20px;
border: 2px solid;
background-color: yellow;
} (a) 2px solid (b) h2 (c) .box (d) font-size - 35.🧩 Which language makes a link? (a) HTML (b) CSS (c) JavaScript
-
36.✍️ What is the selector in this CSS rule?
.box {
width: 300px;
color: red;
font-style: italic;
} (a) h2 (b) width (c) red (d) .box -
37.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 160px;
padding: 25px;
border: 4px solid black;
margin: 20px;
} - 38.🔍 Which is the odd one out? (a) changes the text size (b) makes a link (c) rounds box corners (d) sets colours and fonts
- 39.🌈 Which colour is rgb(255, 0, 255)? (a) blue (b) magenta (c) cyan (d) bright green
-
40.✍️ What value is given to margin in this rule?
li {
margin: 10px;
background-color: yellow;
} (a) 8px (b) margin (c) bold (d) 10px
Answer key
- text-align
- 8px
- <div id="logo">
- 12
- 40
- green
- red
- flex-start
- black
- black
- #main
- cyan
- <link>
- red
- False
- True
- white
- <li id="logo">
- 20
- 4
- magenta
- colours behind the text
- { }
- an element selector
- an id selector
- display: flex
- CSS
- #logo
- space outside the border
- HTML
- blue
- <li class="note">
- red
- .box
- HTML
- .box
- 258
- makes a link
- magenta
- 10px
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids