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.✍️ Which property is set to center in this rule?
h1 {
text-align: center;
font-style: italic;
color: red;
font-weight: bold;
} (a) text-align (b) background-color (c) center (d) margin -
2.⚖️ What colour is the text of this element?
<h1 class="red" id="main">Hi</h1>
CSS:
.red { color: purple; }
#main { color: yellow; }
h1 { color: red; } (a) yellow (b) white (c) red (d) purple - 3.🎯 Which element does the selector div style? (a) <h1 id="main"> (b) <p class="big"> (c) <div class="big"> (d) <span>
- 4.📱 Responsive design means a page ___. (a) never changes (b) is only for laptops (c) has no pictures (d) fits every screen
-
5.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 768px) {
p {
font-size: 14px;
}
} - 6.🔍 Which is the odd one out? (a) rounds box corners (b) adds space around boxes (c) changes the text size (d) changes the page live
- 7.🌈 In #00bd00 the green part is the hex number bd. What is it as a normal number?
- 8.True or false: p is an id selector. (a) True (b) False
-
9.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 20px;
}
} (a) No (b) Yes - 10.📦 In the box model, which part is the gap round content? (a) content (b) padding (c) border (d) margin
- 11.✍️ In color: blue; which part is the property? (a) blue (b) : (c) ; (d) color
- 12.True or false: JavaScript shows a pop-up message. (a) False (b) True
-
13.✍️ How many declarations (property: value pairs) are in this rule?
p {
color: red;
margin: 10px;
font-size: 20px;
padding: 8px;
} - 14.What does justify-content: flex-end do? (a) puts boxes in the middle (b) equal gaps, none at ends (c) packs boxes at the start (d) packs boxes at the end
- 15.🎯 Can many elements share the same class? (a) No (b) Yes
-
16.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 120px;
padding: 30px;
border: 4px solid black;
margin: 0px;
} - 17.🎨 Which attribute adds CSS inside one tag? (a) href (b) style (c) alt (d) src
- 18.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) red (c) black (d) blue
- 19.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
-
20.🎯 Which CSS selector matches this element?
<h1 class="box" id="end">Hello</h1> (a) .star (b) h2 (c) .end (d) .box -
21.✍️ What value is given to border in this rule?
h1 {
color: red;
border: 2px solid;
font-size: 20px;
margin: 10px;
} (a) italic (b) 2px solid (c) 300px (d) border -
22.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 240px;
padding: 25px;
border: 5px solid black;
margin: 0px;
} -
23.⚖️ What colour is the text of this element?
<h1 class="menu" id="end">Hi</h1>
CSS:
.menu { color: red; }
.menu { color: green; } (a) orange (b) red (c) black (d) green -
24.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 22px;
}
} -
25.🖌️ Where does the text sit on its line?
h2 {
text-align: right;
background-color: blue;
font-size: 24px;
color: black;
} (a) in the middle (b) on the right (c) on the left - 26.🌈 What is the biggest number one colour can have in rgb()? (a) 99 (b) 1000 (c) 255 (d) 100
- 27.🔍 Which is the odd one out? (a) makes a form box (b) puts a picture on a page (c) reacts to a button click (d) makes headings and lists
-
28.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 200px;
justify-content: flex-start;
}
Inside are 3 boxes, each 60px wide (no margins). - 29.True or false: the border is a solid or dotted edge. (a) True (b) False
- 30.Which of these does CSS do? (a) reacts to a button click (b) lays out the page (c) makes headings and lists (d) shows a pop-up message
-
31.✍️ What is the selector in this CSS rule?
#top {
color: red;
border: 2px solid;
font-weight: bold;
} (a) #top (b) 2px solid (c) li (d) color - 32.True or false: the border is the line round the box. (a) False (b) True
-
33.⚖️ What colour is the text of this element?
<h2 class="star" id="top">Hi</h2>
CSS:
.star { color: green; }
.star { color: orange; } (a) red (b) blue (c) green (d) orange -
34.🎯 Which CSS selector matches this element?
<span class="menu" id="intro">Hello</span> (a) #main (b) .menu (c) #menu (d) .note -
35.🖌️ What colour are the letters?
h1 {
background-color: yellow;
font-size: 28px;
text-align: center;
color: black;
} (a) white (b) yellow (c) black -
36.✍️ What is the selector in this CSS rule?
p {
border: 2px solid;
font-style: italic;
color: red;
} (a) italic (b) border (c) p (d) .note - 37.✍️ Which sign ends each CSS declaration? (a) . (b) : (c) , (d) ;
-
38.✍️ How many declarations (property: value pairs) are in this rule?
li {
text-align: center;
font-style: italic;
font-weight: bold;
border: 2px solid;
} -
39.⚖️ What colour is the text of this element?
<h2 class="box" id="end">Hi</h2>
CSS:
#end { color: red; }
.box { color: yellow; } (a) yellow (b) blue (c) green (d) red - 40.🎯 What kind of selector is #logo? (a) a class selector (b) an element selector (c) an id selector
Answer key
- text-align
- yellow
- <div class="big">
- fits every screen
- 16
- changes the page live
- 189
- False
- No
- padding
- color
- True
- 4
- packs boxes at the end
- Yes
- 188
- style
- red
- an element selector
- .box
- 2px solid
- 300
- green
- 22
- on the right
- 255
- reacts to a button click
- 20
- True
- lays out the page
- #top
- True
- orange
- .menu
- black
- p
- ;
- 4
- red
- an id selector
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids