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.🎯 How many elements on a page should have the same id? (a) 1 (b) any number (c) 2 (d) 5
-
2.⚖️ What colour is the text of this element?
<h2 class="menu" id="intro">Hi</h2>
CSS:
h2 { color: white; }
#intro { color: orange; } (a) blue (b) orange (c) purple (d) white -
3.✍️ Which property is set to 20px in this rule?
p {
text-align: center;
font-size: 20px;
} (a) background-color (b) font-size (c) text-align (d) 20px - 4.Which of these does CSS do? (a) reacts to a button click (b) puts a picture on a page (c) makes a form box (d) changes the text size
- 5.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) exactly 1000px (c) turned off (d) 600px or narrower
-
6.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 220px;
justify-content: space-between;
}
Inside are 4 boxes, each 40px wide (no margins). - 7.🔍 Which is the odd one out? (a) changes the page live (b) shows a pop-up message (c) gives the page structure (d) counts down a timer
- 8.🌈 In #2c0000 the red part is the hex number 2c. What is it as a normal number?
-
9.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 10px;
}
} (a) Yes (b) No -
10.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 280px;
justify-content: flex-end;
}
Inside are 4 boxes, each 50px wide (no margins). - 11.🌈 In #rrggbb, which colour do the first two digits give? (a) red (b) black (c) blue (d) green
-
12.🎯 Which CSS selector matches this element?
<h1 class="big" id="intro">Hello</h1> (a) #big (b) h2 (c) h1 (d) #main -
13.🎯 Which CSS selector matches this element?
<h1 class="big" id="end">Hello</h1> (a) h2 (b) .red (c) h1 (d) #hero -
14.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 200px;
justify-content: flex-end;
}
Inside are 4 boxes, each 40px wide (no margins). - 15.✍️ In color: blue; which part is the value? (a) color (b) : (c) blue (d) ;
-
16.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 200px;
padding: 15px;
border: 1px solid black;
margin: 15px;
} - 17.🔍 Which is the odd one out? (a) makes headings and lists (b) puts a picture on a page (c) makes a link (d) checks a quiz answer
- 18.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) blue (c) green (d) white
-
19.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 1024px) {
p {
font-size: 22px;
}
} - 20.🧩 Which language lays out the page? (a) JavaScript (b) CSS (c) HTML
-
21.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 200px;
padding: 25px;
border: 1px solid black;
margin: 20px;
} -
22.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 320px;
justify-content: space-between;
}
Inside are 4 boxes, each 50px wide (no margins). -
23.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 1024px) {
p {
font-size: 26px;
}
} (a) No (b) Yes -
24.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 1024px) {
p {
font-size: 14px;
}
} - 25.🌈 Which colour is rgb(0, 0, 255)? (a) yellow (b) black (c) red (d) blue
-
26.✍️ What value is given to background-color in this rule?
h2 {
border: 2px solid;
color: red;
background-color: yellow;
width: 300px;
} (a) 10px (b) background-color (c) yellow (d) 8px - 27.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
-
28.✍️ How many declarations (property: value pairs) are in this rule?
li {
width: 300px;
} -
29.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 80px;
padding: 20px;
border: 5px solid black;
margin: 0px;
} -
30.✍️ How many declarations (property: value pairs) are in this rule?
.note {
width: 300px;
} - 31.🎯 Which element does the selector #top style? (a) <p id="intro"> (b) <h1 class="box"> (c) <p class="top"> (d) <p id="top">
- 32.✍️ Which sign ends each CSS declaration? (a) ; (b) . (c) : (d) ,
-
33.🖌️ Where does the text sit on its line?
h2 {
font-size: 32px;
background-color: purple;
text-align: center;
color: green;
} (a) on the right (b) on the left (c) in the middle -
34.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 250px;
padding: 25px;
border: 5px solid black;
margin: 15px;
} - 35.🖌️ Which CSS property sets the letter colour? (a) font-family (b) color (c) background-color (d) font-size
-
36.✍️ What is the selector in this CSS rule?
#top {
text-align: center;
font-size: 20px;
font-style: italic;
} (a) text-align (b) 20px (c) li (d) #top - 37.True or false: JavaScript rounds box corners. (a) False (b) True
- 38.🌈 Which colour is rgb(255, 0, 255)? (a) yellow (b) white (c) magenta (d) bright green
-
39.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 90px;
justify-content: flex-start;
}
Inside are 2 boxes, each 40px wide (no margins). - 40.📦 In the box model, which part is the line round the box? (a) padding (b) margin (c) content (d) border
Answer key
- 1
- orange
- font-size
- changes the text size
- 600px or narrower
- 20
- gives the page structure
- 44
- No
- 80
- red
- h1
- h1
- 40
- blue
- 262
- checks a quiz answer
- blue
- 22
- CSS
- 252
- 40
- Yes
- 14
- blue
- yellow
- an id selector
- 1
- 130
- 1
- <p id="top">
- ;
- in the middle
- 340
- color
- #top
- False
- magenta
- 10
- border
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids