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.✍️ What value is given to padding in this rule?
h2 {
padding: 8px;
font-weight: bold;
} (a) bold (b) 2px solid (c) padding (d) 8px - 2.True or false: padding is a solid or dotted edge. (a) False (b) True
- 3.True or false: padding is space inside the border. (a) True (b) False
- 4.🎨 Which tag connects an outside CSS file? (a) <css> (b) <img> (c) <link> (d) <a>
- 5.Which of these is padding? (a) the line round the box (b) the text or picture (c) a solid or dotted edge (d) the gap round content
- 6.🌈 Which colour of light is strongest in rgb(192, 117, 133)? (a) green (b) red (c) blue
-
7.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 10px;
}
} (a) Yes (b) No -
8.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 130px;
padding: 5px;
border: 4px solid black;
margin: 5px;
} - 9.🧩 Which language rounds box corners? (a) JavaScript (b) HTML (c) CSS
- 10.🎯 What kind of selector is #hero? (a) a class selector (b) an id selector (c) an element selector
- 11.📦 In the box model, which part is a solid or dotted edge? (a) content (b) border (c) padding (d) margin
- 12.True or false: JavaScript counts down a timer. (a) False (b) True
- 13.🔍 Which is the odd one out? (a) puts a picture on a page (b) gives the page structure (c) shows a pop-up message (d) makes a link
-
14.⚖️ What colour is the text of this element?
<h2 class="red" id="hero">Hi</h2>
CSS:
.red { color: purple; }
.red { color: black; } (a) white (b) red (c) black (d) purple - 15.🧩 Which language lays out the page? (a) HTML (b) CSS (c) JavaScript
-
16.✍️ What value is given to width in this rule?
li {
width: 300px;
padding: 8px;
color: red;
} (a) width (b) red (c) italic (d) 300px -
17.⚖️ What colour is the text of this element?
<p class="red" id="end">Hi</p>
CSS:
#end { color: black; }
.red { color: red; }
p { color: purple; } (a) orange (b) black (c) red (d) purple - 18.✍️ How does a CSS comment start? (a) /* (b) // (c) <!-- (d) #
- 19.🎯 What kind of selector is li? (a) an id selector (b) an element selector (c) a class selector
- 20.🧩 Which language changes the text size? (a) CSS (b) HTML (c) JavaScript
-
21.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 320px;
justify-content: flex-start;
}
Inside are 3 boxes, each 100px wide (no margins). - 22.What does justify-content: center do? (a) equal gaps, none at ends (b) packs boxes at the start (c) puts boxes in the middle (d) packs boxes at the end
- 23.🎯 Can many elements share the same class? (a) Yes (b) No
- 24.True or false: CSS rounds box corners. (a) False (b) True
-
25.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 210px;
padding: 30px;
border: 5px solid black;
margin: 5px;
} -
26.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 150px;
justify-content: flex-end;
}
Inside are 2 boxes, each 40px wide (no margins). -
27.🎯 Which CSS selector matches this element?
<h1 class="big" id="logo">Hello</h1> (a) h1 (b) .logo (c) #big (d) .red - 28.What does font-size do? (a) colours behind the text (b) picks the font style (c) sets the letter colour (d) makes letters bigger
-
29.✍️ How many declarations (property: value pairs) are in this rule?
.note {
padding: 8px;
} -
30.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 210px;
justify-content: flex-start;
}
Inside are 3 boxes, each 60px wide (no margins). - 31.💪 Which justify-content value equal gaps, none at ends? (a) flex-end (b) center (c) flex-start (d) space-between
- 32.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) exactly 1000px (c) 600px or wider (d) 600px or narrower
- 33.🔍 Which is the odd one out? (a) puts a picture on a page (b) makes a form box (c) adds space around boxes (d) makes headings and lists
-
34.🖌️ How big is the text, in px?
li {
font-size: 20px;
background-color: white;
color: purple;
text-align: right;
} -
35.✍️ How many declarations (property: value pairs) are in this rule?
.box {
padding: 8px;
} - 36.💪 Which flexbox property picks row or column? (a) align-items (b) display: flex (c) gap (d) flex-direction
- 37.✍️ In color: blue; which part is the property? (a) : (b) color (c) blue (d) ;
- 38.Which of these does JavaScript do? (a) shows a pop-up message (b) puts a picture on a page (c) rounds box corners (d) changes the text size
-
39.⚖️ What colour is the text of this element?
<h1 class="box" id="intro">Hi</h1>
CSS:
h1 { color: red; }
h1 { color: black; } (a) red (b) black (c) green (d) orange - 40.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the later one (c) the first one (d) neither
Answer key
- 8px
- False
- True
- <link>
- the gap round content
- red
- No
- 158
- CSS
- an id selector
- border
- True
- shows a pop-up message
- black
- CSS
- 300px
- black
- /*
- an element selector
- CSS
- 20
- puts boxes in the middle
- Yes
- True
- 290
- 70
- h1
- makes letters bigger
- 1
- 30
- space-between
- 600px or narrower
- adds space around boxes
- 20
- 1
- flex-direction
- color
- shows a pop-up message
- black
- the later one
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids