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 background-color in this rule?
h2 {
font-weight: bold;
color: red;
background-color: yellow;
} (a) background-color (b) 8px (c) yellow (d) 10px - 2.Which of these does HTML do? (a) rounds box corners (b) reacts to a button click (c) counts down a timer (d) makes a link
-
3.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: flex-end;
}
Inside are 2 boxes, each 100px wide (no margins). -
4.🎯 Which CSS selector matches this element?
<h1 class="red" id="main">Hello</h1> (a) h2 (b) .red (c) .main (d) #logo - 5.What does font-weight do? (a) makes the text bold (b) makes letters bigger (c) colours behind the text (d) centres a heading
- 6.True or false: #top is an element selector. (a) False (b) True
- 7.🎯 What kind of selector is #logo? (a) a class selector (b) an id selector (c) an element selector
-
8.⚖️ What colour is the text of this element?
<h1 class="note" id="logo">Hi</h1>
CSS:
#logo { color: orange; }
.note { color: black; }
h1 { color: red; } (a) orange (b) purple (c) red (d) black - 9.📦 In the box model, which part is space outside the border? (a) padding (b) margin (c) border (d) content
- 10.🎯 What kind of selector is #end? (a) an element selector (b) a class selector (c) an id selector
-
11.🖌️ Where does the text sit on its line?
li {
text-align: right;
font-size: 12px;
background-color: yellow;
color: blue;
} (a) on the right (b) on the left (c) in the middle -
12.⚖️ What colour is the text of this element?
<h2 class="big" id="main">Hi</h2>
CSS:
#main { color: blue; }
#main { color: purple; } (a) green (b) blue (c) red (d) purple -
13.⚖️ What colour is the text of this element?
<p class="star" id="top">Hi</p>
CSS:
.star { color: orange; }
.star { color: red; } (a) purple (b) blue (c) orange (d) red -
14.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 200px;
justify-content: center;
}
Inside are 2 boxes, each 50px wide (no margins). - 15.🧩 Which language changes the text size? (a) JavaScript (b) HTML (c) CSS
-
16.🎯 Which CSS selector matches this element?
<span class="red" id="top">Hello</span> (a) .box (b) p (c) #top (d) .top -
17.⚖️ What colour is the text of this element?
<h2 class="box" id="intro">Hi</h2>
CSS:
#intro { color: green; }
#intro { color: red; } (a) blue (b) white (c) green (d) red - 18.🧩 Which language rounds box corners? (a) CSS (b) JavaScript (c) HTML
- 19.🧩 Which language sets colours and fonts? (a) JavaScript (b) CSS (c) HTML
- 20.📦 In the box model, which part is the text or picture? (a) padding (b) border (c) margin (d) content
-
21.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 440px;
justify-content: space-between;
}
Inside are 4 boxes, each 50px wide (no margins). - 22.🌈 Which hex code is blue? (a) #00ffff (b) #ffff00 (c) #0000ff (d) #000000
- 23.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) neither (c) the first one (d) the later one
- 24.📱 Responsive design means a page ___. (a) is only for laptops (b) never changes (c) fits every screen (d) has no pictures
- 25.🌈 Which colour is #00ff00? (a) bright green (b) cyan (c) yellow (d) white
- 26.What does justify-content: flex-start do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the start (d) packs boxes at the end
-
27.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 20px;
}
} - 28.Which of these is margin? (a) the text or picture (b) the line round the box (c) space outside the border (d) space inside the border
- 29.🎯 Which element does the selector .star style? (a) <h2 class="star"> (b) <h2 class="menu"> (c) <h2 id="star"> (d) <li class="note">
- 30.What does background-color do? (a) makes the text bold (b) sets the letter colour (c) centres a heading (d) colours behind the text
- 31.✍️ CSS declarations go inside which brackets? (a) ( ) (b) { } (c) [ ] (d) < >
- 32.Which of these does HTML do? (a) shows a pop-up message (b) makes headings and lists (c) rounds box corners (d) changes the page live
- 33.Which of these does CSS do? (a) makes headings and lists (b) counts down a timer (c) sets colours and fonts (d) shows a pop-up message
-
34.🎯 Which CSS selector matches this element?
<p class="note" id="intro">Hello</p> (a) #intro (b) .intro (c) #main (d) h1 - 35.True or false: JavaScript makes a link. (a) False (b) True
- 36.🖌️ Which CSS property picks the font style? (a) text-align (b) background-color (c) font-family (d) color
- 37.What does text-align do? (a) centres a heading (b) sets the letter colour (c) makes letters bigger (d) makes the text bold
-
38.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 1024px) {
p {
font-size: 26px;
}
} -
39.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 14px;
}
} (a) No (b) Yes -
40.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 28px;
}
} (a) Yes (b) No
Answer key
- yellow
- makes a link
- 60
- .red
- makes the text bold
- False
- an id selector
- orange
- margin
- an id selector
- on the right
- purple
- red
- 50
- CSS
- #top
- red
- CSS
- CSS
- content
- 80
- #0000ff
- the later one
- fits every screen
- bright green
- packs boxes at the start
- 12
- space outside the border
- <h2 class="star">
- colours behind the text
- { }
- makes headings and lists
- sets colours and fonts
- #intro
- False
- font-family
- centres a heading
- 26
- No
- No
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids