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.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 280px;
padding: 20px;
border: 1px solid black;
margin: 0px;
} -
2.✍️ Which property is set to center in this rule?
#top {
font-size: 20px;
text-align: center;
font-weight: bold;
} (a) background-color (b) margin (c) text-align (d) center - 3.🎨 Which attribute adds CSS inside one tag? (a) alt (b) src (c) style (d) href
- 4.🌈 In #580000 the red part is the hex number 58. What is it as a normal number?
- 5.🌈 Which colour is #ffff00? (a) cyan (b) magenta (c) blue (d) yellow
- 6.What does justify-content: flex-end do? (a) equal gaps, none at ends (b) packs boxes at the end (c) packs boxes at the start (d) puts boxes in the middle
-
7.⚖️ What colour is the text of this element?
<h1 class="red" id="hero">Hi</h1>
CSS:
.red { color: black; }
#hero { color: orange; } (a) green (b) orange (c) blue (d) black - 8.🧩 Which language shows a pop-up message? (a) JavaScript (b) HTML (c) CSS
- 9.🎨 Which tag connects an outside CSS file? (a) <css> (b) <link> (c) <a> (d) <img>
- 10.🔍 Which is the odd one out? (a) changes the page live (b) checks a quiz answer (c) shows a pop-up message (d) gives the page structure
- 11.Which of these is the border? (a) the text or picture (b) a solid or dotted edge (c) space inside the border (d) space outside the border
- 12.📦 In the box model, which part is a solid or dotted edge? (a) content (b) margin (c) padding (d) border
- 13.🎯 Which element does the selector h1 style? (a) <h2> (b) <li class="note"> (c) <h1 class="note"> (d) <div id="end">
- 14.🌈 In #fd0000 the red part is the hex number fd. What is it as a normal number?
-
15.🖌️ What colour are the letters?
h1 {
font-size: 28px;
background-color: yellow;
color: blue;
text-align: center;
} (a) orange (b) blue (c) yellow -
16.📦 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: 2px solid black;
margin: 0px;
} -
17.🎯 Which CSS selector matches this element?
<li class="box" id="top">Hello</li> (a) .top (b) #intro (c) li (d) .star -
18.✍️ What value is given to padding in this rule?
#top {
border: 2px solid;
padding: 8px;
} (a) 2px solid (b) 8px (c) bold (d) padding - 19.⚖️ Which selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
-
20.✍️ Which property is set to center in this rule?
.box {
font-size: 20px;
text-align: center;
width: 300px;
} (a) text-align (b) background-color (c) center (d) margin - 21.🧩 Which language makes a link? (a) CSS (b) JavaScript (c) HTML
-
22.⚖️ What colour is the text of this element?
<p class="star" id="intro">Hi</p>
CSS:
#intro { color: red; }
#intro { color: green; } (a) green (b) blue (c) red (d) yellow -
23.✍️ What value is given to width in this rule?
#top {
border: 2px solid;
font-weight: bold;
width: 300px;
} (a) red (b) italic (c) 300px (d) width - 24.True or false: .big is an id selector. (a) False (b) True
-
25.✍️ What is the selector in this CSS rule?
h1 {
text-align: center;
font-weight: bold;
font-style: italic;
width: 300px;
} (a) text-align (b) p (c) bold (d) h1 - 26.📦 In the box model, which part is the text or picture? (a) margin (b) border (c) content (d) padding
-
27.⚖️ What colour is the text of this element?
<p class="note" id="intro">Hi</p>
CSS:
#intro { color: purple; }
#intro { color: black; } (a) black (b) green (c) purple (d) red - 28.True or false: .menu is an element selector. (a) True (b) False
- 29.🎯 How many elements on a page should have the same id? (a) 5 (b) any number (c) 2 (d) 1
-
30.⚖️ What colour is the text of this element?
<h1 class="star" id="main">Hi</h1>
CSS:
.star { color: green; }
h1 { color: blue; } (a) green (b) purple (c) blue (d) red -
31.⚖️ What colour is the text of this element?
<p class="menu" id="end">Hi</p>
CSS:
#end { color: orange; }
#end { color: red; } (a) white (b) black (c) orange (d) red - 32.💪 Which justify-content value packs boxes at the start? (a) center (b) flex-end (c) flex-start (d) space-between
-
33.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 14px;
}
} -
34.✍️ Which property is set to 8px in this rule?
body {
border: 2px solid;
margin: 10px;
padding: 8px;
} (a) border (b) font-weight (c) 8px (d) padding - 35.🌈 Which colour is #ff00ff? (a) bright green (b) cyan (c) blue (d) magenta
- 36.🔍 Which is the odd one out? (a) counts down a timer (b) checks a quiz answer (c) shows a pop-up message (d) makes a form box
- 37.✍️ In color: blue; which part is the property? (a) : (b) blue (c) ; (d) color
-
38.💪 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 40px wide (no margins). - 39.True or false: the border is the text or picture. (a) True (b) False
- 40.💪 Which flexbox property turns on flexbox? (a) align-items (b) display: flex (c) gap (d) justify-content
Answer key
- 322
- text-align
- style
- 88
- yellow
- packs boxes at the end
- orange
- JavaScript
- <link>
- gives the page structure
- a solid or dotted edge
- border
- <h1 class="note">
- 253
- blue
- 164
- li
- 8px
- an id selector
- text-align
- HTML
- green
- 300px
- False
- h1
- content
- black
- False
- 1
- green
- red
- flex-start
- 14
- padding
- magenta
- makes a form box
- color
- 40
- False
- display: flex
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids