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 text-align in this rule?
.note {
font-size: 20px;
text-align: center;
} (a) center (b) 10px (c) yellow (d) text-align - 2.True or false: .big is an id selector. (a) True (b) False
-
3.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 280px;
justify-content: space-between;
}
Inside are 3 boxes, each 80px wide (no margins). - 4.✍️ Which sign ends each CSS declaration? (a) , (b) ; (c) . (d) :
- 5.🔍 Which is the odd one out? (a) reacts to a button click (b) sets colours and fonts (c) checks a quiz answer (d) shows a pop-up message
- 6.What does justify-content: center do? (a) packs boxes at the start (b) equal gaps, none at ends (c) puts boxes in the middle (d) packs boxes at the end
-
7.✍️ What is the selector in this CSS rule?
.note {
font-size: 20px;
font-weight: bold;
font-style: italic;
} (a) #top (b) bold (c) font-size (d) .note -
8.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 600px) {
p {
font-size: 18px;
}
} (a) No (b) Yes -
9.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
text-align: center;
} - 10.📦 In the box model, which part is space outside the border? (a) border (b) padding (c) content (d) margin
-
11.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 160px;
justify-content: space-between;
}
Inside are 2 boxes, each 40px wide (no margins). - 12.✍️ CSS declarations go inside which brackets? (a) { } (b) [ ] (c) < > (d) ( )
- 13.🎯 Which element does the selector p style? (a) <li id="end"> (b) <h1> (c) <h2 class="box"> (d) <p class="box">
-
14.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 180px;
padding: 15px;
border: 4px solid black;
margin: 20px;
} - 15.🌈 In #d30000 the red part is the hex number d3. What is it as a normal number?
- 16.🎯 Which element does the selector h1 style? (a) <li class="box"> (b) <h1 class="box"> (c) <div id="logo"> (d) <h2>
- 17.💪 Which justify-content value packs boxes at the end? (a) space-between (b) center (c) flex-start (d) flex-end
- 18.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
-
19.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 150px;
padding: 30px;
border: 5px solid black;
margin: 10px;
} - 20.🧩 Which language adds space around boxes? (a) JavaScript (b) HTML (c) CSS
- 21.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
- 22.True or false: JavaScript lays out the page. (a) False (b) True
- 23.What does font-family do? (a) centres a heading (b) picks the font style (c) makes letters bigger (d) colours behind the text
-
24.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 10px;
}
} (a) No (b) Yes -
25.✍️ How many declarations (property: value pairs) are in this rule?
p {
color: red;
border: 2px solid;
margin: 10px;
} - 26.📱 Which tag helps phones show a page at the right size? (a) the viewport meta tag (b) the title tag (c) the hr tag (d) the br tag
-
27.💪 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 50px wide (no margins). - 28.🖌️ Which CSS property picks the font style? (a) font-weight (b) text-align (c) font-family (d) background-color
- 29.🎯 What kind of selector is #main? (a) an id selector (b) a class selector (c) an element selector
- 30.🔍 Which is the odd one out? (a) makes headings and lists (b) puts a picture on a page (c) reacts to a button click (d) makes a form box
- 31.What does justify-content: space-between do? (a) packs boxes at the end (b) packs boxes at the start (c) puts boxes in the middle (d) equal gaps, none at ends
-
32.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 100px;
padding: 5px;
border: 2px solid black;
margin: 10px;
} -
33.⚖️ What colour is the text of this element?
<h2 class="menu" id="hero">Hi</h2>
CSS:
h2 { color: green; }
h2 { color: blue; } (a) green (b) orange (c) blue (d) yellow - 34.🌈 Which colour is #ffff00? (a) white (b) bright green (c) yellow (d) red
- 35.Which of these does CSS do? (a) checks a quiz answer (b) changes the page live (c) lays out the page (d) makes headings and lists
- 36.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) white (c) red (d) green
- 37.🎯 Which sign starts a class selector? (a) & (b) @ (c) . (d) #
- 38.💪 Which justify-content value puts boxes in the middle? (a) flex-start (b) space-between (c) center (d) flex-end
- 39.✍️ In color: blue; which part is the property? (a) blue (b) color (c) : (d) ;
- 40.🌈 Which colour of light is strongest in rgb(8, 197, 44)? (a) blue (b) green (c) red
Answer key
- center
- False
- 20
- ;
- sets colours and fonts
- puts boxes in the middle
- .note
- Yes
- 1
- margin
- 80
- { }
- <p class="box">
- 258
- 211
- <h1 class="box">
- flex-end
- an element selector
- 220
- CSS
- an id selector
- False
- picks the font style
- Yes
- 3
- the viewport meta tag
- 20
- font-family
- an id selector
- reacts to a button click
- equal gaps, none at ends
- 114
- blue
- yellow
- lays out the page
- blue
- .
- center
- color
- green
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids