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 does font-family do? (a) makes letters bigger (b) sets the letter colour (c) centres a heading (d) picks the font style
-
2.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
text-align: center;
color: red;
} -
3.🖌️ What colour are the letters?
h2 {
background-color: blue;
color: green;
font-size: 36px;
text-align: left;
} (a) blue (b) purple (c) green - 4.🎯 Which sign starts a class selector? (a) # (b) . (c) @ (d) &
-
5.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 190px;
padding: 20px;
border: 3px solid black;
margin: 10px;
} -
6.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 18px;
}
} (a) Yes (b) No -
7.🎯 Which CSS selector matches this element?
<p class="menu" id="hero">Hello</p> (a) #menu (b) p (c) #top (d) h1 - 8.🌈 Which colour of light is strongest in rgb(37, 74, 221)? (a) red (b) blue (c) green
- 9.🎨 Which attribute adds CSS inside one tag? (a) style (b) href (c) alt (d) src
- 10.🔍 Which is the odd one out? (a) changes the text size (b) changes the page live (c) adds space around boxes (d) lays out the page
-
11.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 210px;
justify-content: flex-start;
}
Inside are 2 boxes, each 80px wide (no margins). - 12.True or false: JavaScript counts down a timer. (a) False (b) True
-
13.⚖️ What colour is the text of this element?
<h2 class="red" id="end">Hi</h2>
CSS:
#end { color: red; }
#end { color: black; } (a) blue (b) yellow (c) red (d) black - 14.🌈 Which colour is #ffff00? (a) blue (b) bright green (c) yellow (d) white
-
15.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 14px;
}
} - 16.🌈 Which hex code is blue? (a) #ff00ff (b) #ffffff (c) #0000ff (d) #ff0000
-
17.⚖️ What colour is the text of this element?
<p class="note" id="main">Hi</p>
CSS:
.note { color: black; }
#main { color: purple; }
p { color: yellow; } (a) yellow (b) black (c) purple (d) orange -
18.✍️ How many declarations (property: value pairs) are in this rule?
p {
text-align: center;
width: 300px;
} - 19.🎯 Which element does the selector #logo style? (a) <span class="red"> (b) <div id="end"> (c) <div id="logo"> (d) <div class="logo">
-
20.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 768px) {
p {
font-size: 32px;
}
} (a) Yes (b) No - 21.🧩 Which language reacts to a button click? (a) HTML (b) CSS (c) JavaScript
-
22.✍️ What is the selector in this CSS rule?
li {
border: 2px solid;
padding: 8px;
font-size: 20px;
} (a) 8px (b) li (c) border (d) body - 23.✍️ How does a CSS comment start? (a) # (b) // (c) /* (d) <!--
-
24.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 160px;
padding: 25px;
border: 3px solid black;
margin: 5px;
} - 25.🌈 Which colour of light is strongest in rgb(33, 229, 122)? (a) blue (b) red (c) green
- 26.🎯 What kind of selector is img? (a) a class selector (b) an element selector (c) an id selector
-
27.⚖️ What colour is the text of this element?
<h1 class="note" id="intro">Hi</h1>
CSS:
h1 { color: orange; }
.note { color: blue; } (a) green (b) orange (c) blue (d) white - 28.✍️ CSS declarations go inside which brackets? (a) < > (b) { } (c) [ ] (d) ( )
-
29.⚖️ What colour is the text of this element?
<h2 class="big" id="hero">Hi</h2>
CSS:
h2 { color: white; }
h2 { color: black; } (a) black (b) white (c) blue (d) green -
30.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 60px;
padding: 25px;
border: 5px solid black;
margin: 10px;
} - 31.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) black (c) blue (d) red
-
32.✍️ How many declarations (property: value pairs) are in this rule?
body {
border: 2px solid;
font-size: 20px;
} - 33.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
- 34.🎯 What kind of selector is .star? (a) an id selector (b) an element selector (c) a class selector
-
35.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 28px;
}
} -
36.⚖️ What colour is the text of this element?
<h2 class="box" id="hero">Hi</h2>
CSS:
.box { color: orange; }
h2 { color: yellow; }
#hero { color: black; } (a) orange (b) black (c) blue (d) yellow -
37.🎯 Which CSS selector matches this element?
<li class="red" id="intro">Hello</li> (a) div (b) .intro (c) #red (d) .red -
38.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 170px;
padding: 15px;
border: 4px solid black;
margin: 15px;
} -
39.🖌️ What colour is behind the letters?
h2 {
text-align: right;
font-size: 16px;
color: purple;
background-color: yellow;
} (a) yellow (b) purple (c) red -
40.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
font-size: 20px;
font-weight: bold;
color: red;
}
Answer key
- picks the font style
- 2
- green
- .
- 236
- No
- p
- blue
- style
- changes the page live
- 50
- True
- black
- yellow
- 14
- #0000ff
- purple
- 2
- <div id="logo">
- No
- JavaScript
- li
- /*
- 226
- green
- an element selector
- blue
- { }
- black
- 120
- red
- 2
- an id selector
- a class selector
- 28
- black
- .red
- 238
- yellow
- 3
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids