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 colour are the letters?
p {
font-size: 36px;
text-align: center;
background-color: red;
color: blue;
} (a) blue (b) orange (c) red -
2.⚖️ What colour is the text of this element?
<h2 class="star" id="logo">Hi</h2>
CSS:
.star { color: orange; }
#logo { color: white; }
h2 { color: red; } (a) white (b) red (c) yellow (d) orange -
3.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 10px;
}
} (a) No (b) Yes -
4.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 300px;
padding: 10px;
border: 1px solid black;
margin: 5px;
} -
5.✍️ Which property is set to bold in this rule?
p {
margin: 10px;
font-weight: bold;
} (a) font-weight (b) bold (c) width (d) border - 6.🌈 Which hex code is red? (a) #ff0000 (b) #00ffff (c) #0000ff (d) #00ff00
- 7.🎯 Which sign starts a class selector? (a) & (b) @ (c) . (d) #
-
8.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 20px;
}
} (a) Yes (b) No - 9.What does justify-content: center do? (a) packs boxes at the end (b) equal gaps, none at ends (c) packs boxes at the start (d) puts boxes in the middle
- 10.🌈 Which colour is #ffff00? (a) white (b) blue (c) bright green (d) yellow
- 11.📱 What does a media query check? (a) the time of day (b) the screen width (c) the battery level (d) the page title
-
12.⚖️ What colour is the text of this element?
<h1 class="star" id="logo">Hi</h1>
CSS:
h1 { color: blue; }
h1 { color: black; } (a) blue (b) red (c) white (d) black -
13.⚖️ What colour is the text of this element?
<p class="big" id="end">Hi</p>
CSS:
p { color: yellow; }
p { color: green; } (a) white (b) yellow (c) red (d) green - 14.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) neither (c) the later one (d) the first one
- 15.🎯 What kind of selector is #top? (a) a class selector (b) an id selector (c) an element selector
- 16.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
- 17.🎯 What kind of selector is .star? (a) a class selector (b) an id selector (c) an element selector
- 18.Which of these is padding? (a) a solid or dotted edge (b) the line round the box (c) space inside the border (d) the text or picture
- 19.🌈 In #7e0000 the red part is the hex number 7e. What is it as a normal number?
-
20.🎯 Which CSS selector matches this element?
<div class="big" id="main">Hello</div> (a) span (b) #big (c) .main (d) .big - 21.True or false: padding is the gap to other boxes. (a) False (b) True
-
22.⚖️ What colour is the text of this element?
<p class="menu" id="top">Hi</p>
CSS:
.menu { color: orange; }
.menu { color: green; } (a) orange (b) yellow (c) blue (d) green -
23.⚖️ What colour is the text of this element?
<h2 class="star" id="top">Hi</h2>
CSS:
.star { color: orange; }
.star { color: green; } (a) green (b) orange (c) white (d) blue - 24.Which of these is margin? (a) space outside the border (b) the gap round content (c) the line round the box (d) a solid or dotted edge
- 25.True or false: padding is the gap round content. (a) False (b) True
- 26.Which of these does CSS do? (a) makes a link (b) sets colours and fonts (c) makes headings and lists (d) checks a quiz answer
- 27.🌈 In #0000d4 the blue part is the hex number d4. What is it as a normal number?
- 28.🎯 What kind of selector is #hero? (a) an id selector (b) an element selector (c) a class selector
- 29.🌈 Which colour is rgb(0, 255, 0)? (a) black (b) bright green (c) red (d) blue
-
30.⚖️ What colour is the text of this element?
<p class="menu" id="hero">Hi</p>
CSS:
#hero { color: white; }
p { color: blue; }
.menu { color: black; } (a) orange (b) white (c) blue (d) black -
31.✍️ What value is given to background-color in this rule?
p {
background-color: yellow;
font-weight: bold;
font-style: italic;
margin: 10px;
} (a) 10px (b) background-color (c) yellow (d) 8px -
32.⚖️ What colour is the text of this element?
<p class="red" id="logo">Hi</p>
CSS:
#logo { color: yellow; }
.red { color: orange; } (a) yellow (b) blue (c) orange (d) purple -
33.✍️ What value is given to width in this rule?
li {
color: red;
font-style: italic;
font-weight: bold;
width: 300px;
} (a) italic (b) red (c) width (d) 300px - 34.🧩 Which language counts down a timer? (a) HTML (b) CSS (c) JavaScript
- 35.Which of these does CSS do? (a) changes the text size (b) changes the page live (c) makes a form box (d) shows a pop-up message
-
36.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 120px;
padding: 10px;
border: 4px solid black;
margin: 10px;
} - 37.🌈 Hex digits go 0 to 9, then A to which letter? (a) F (b) J (c) G (d) Z
- 38.🔍 Which is the odd one out? (a) adds space around boxes (b) lays out the page (c) sets colours and fonts (d) reacts to a button click
-
39.🎯 Which CSS selector matches this element?
<li class="big" id="logo">Hello</li> (a) #big (b) .logo (c) .big (d) div - 40.✍️ How does a CSS comment start? (a) <!-- (b) // (c) /* (d) #
Answer key
- blue
- white
- No
- 332
- font-weight
- #ff0000
- .
- No
- puts boxes in the middle
- yellow
- the screen width
- black
- green
- the later one
- an id selector
- an id selector
- a class selector
- space inside the border
- 126
- .big
- False
- green
- green
- space outside the border
- True
- sets colours and fonts
- 212
- an id selector
- bright green
- white
- yellow
- yellow
- 300px
- JavaScript
- changes the text size
- 168
- F
- reacts to a button click
- .big
- /*
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids