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 is the text of this element?
<p class="star" id="top">Hi</p>
CSS:
#top { color: blue; }
#top { color: yellow; } (a) blue (b) black (c) yellow (d) purple - 2.🧩 Which language puts a picture on a page? (a) JavaScript (b) CSS (c) HTML
-
3.✍️ What is the selector in this CSS rule?
h2 {
border: 2px solid;
padding: 8px;
width: 300px;
background-color: yellow;
} (a) 8px (b) h1 (c) h2 (d) border -
4.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 600px) {
p {
font-size: 22px;
}
} -
5.🖌️ Where does the text sit on its line?
h2 {
color: red;
text-align: right;
background-color: green;
font-size: 24px;
} (a) on the left (b) in the middle (c) on the right - 6.🌈 Which colour is rgb(0, 0, 255)? (a) magenta (b) white (c) bright green (d) blue
- 7.🖌️ Which CSS property sets the letter colour? (a) font-family (b) background-color (c) color (d) font-size
- 8.🌈 In #000035 the blue part is the hex number 35. What is it as a normal number?
-
9.✍️ How many declarations (property: value pairs) are in this rule?
p {
padding: 8px;
font-size: 20px;
} -
10.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 40px;
padding: 30px;
border: 4px solid black;
margin: 15px;
} -
11.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 280px;
justify-content: center;
}
Inside are 4 boxes, each 40px wide (no margins). -
12.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 90px;
padding: 15px;
border: 2px solid black;
margin: 20px;
} -
13.⚖️ What colour is the text of this element?
<p class="box" id="main">Hi</p>
CSS:
#main { color: orange; }
#main { color: black; } (a) black (b) purple (c) orange (d) green -
14.🎯 Which CSS selector matches this element?
<li class="red" id="logo">Hello</li> (a) #red (b) .logo (c) #end (d) .red -
15.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 20px;
}
} - 16.🌈 In #rrggbb, which colour do the first two digits give? (a) black (b) blue (c) red (d) green
- 17.🎨 One CSS file can style how many pages? (a) no pages (b) many pages (c) only one image (d) only one word
-
18.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 26px;
}
} - 19.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
-
20.⚖️ What colour is the text of this element?
<h2 class="red" id="logo">Hi</h2>
CSS:
.red { color: green; }
.red { color: yellow; } (a) blue (b) red (c) green (d) yellow -
21.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 80px;
padding: 30px;
border: 3px solid black;
margin: 0px;
} -
22.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 6px;
}
} (a) No (b) Yes -
23.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 40px;
padding: 25px;
border: 2px solid black;
margin: 5px;
} - 24.What does font-family do? (a) colours behind the text (b) picks the font style (c) centres a heading (d) makes letters bigger
- 25.🔍 Which is the odd one out? (a) checks a quiz answer (b) shows a pop-up message (c) counts down a timer (d) puts a picture on a page
- 26.🎯 Which element does the selector li style? (a) <li class="menu"> (b) <span class="menu"> (c) <div> (d) <p id="top">
-
27.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 26px;
}
} -
28.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 120px;
justify-content: space-between;
}
Inside are 2 boxes, each 50px wide (no margins). - 29.True or false: CSS makes headings and lists. (a) False (b) True
- 30.🎯 What kind of selector is h1? (a) a class selector (b) an element selector (c) an id selector
-
31.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 22px;
}
} (a) No (b) Yes -
32.🖌️ What colour are the letters?
h2 {
font-size: 12px;
background-color: green;
text-align: center;
color: black;
} (a) black (b) green (c) orange -
33.🖌️ Where does the text sit on its line?
li {
font-size: 16px;
text-align: right;
color: black;
background-color: orange;
} (a) on the right (b) in the middle (c) on the left - 34.💪 Which justify-content value equal gaps, none at ends? (a) flex-end (b) flex-start (c) space-between (d) center
- 35.🎨 Which attribute adds CSS inside one tag? (a) src (b) href (c) style (d) alt
- 36.📦 In the box model, which part is a solid or dotted edge? (a) padding (b) content (c) border (d) margin
- 37.True or false: CSS lays out the page. (a) True (b) False
- 38.🎯 What kind of selector is .card? (a) a class selector (b) an element selector (c) an id selector
-
39.🖌️ Where does the text sit on its line?
h2 {
text-align: left;
color: green;
font-size: 24px;
background-color: black;
} (a) in the middle (b) on the left (c) on the right -
40.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 110px;
padding: 5px;
border: 5px solid black;
margin: 10px;
}
Answer key
- yellow
- HTML
- h2
- 16
- on the right
- blue
- color
- 53
- 2
- 138
- 60
- 164
- black
- .red
- 24
- red
- many pages
- 26
- an id selector
- yellow
- 146
- Yes
- 104
- picks the font style
- puts a picture on a page
- <li class="menu">
- 26
- 20
- False
- an element selector
- Yes
- black
- on the right
- space-between
- style
- border
- True
- a class selector
- on the left
- 150
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids