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 colour is rgb(255, 255, 255)? (a) white (b) blue (c) cyan (d) magenta
-
2.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 150px;
padding: 30px;
border: 5px solid black;
margin: 10px;
} - 3.🎯 What kind of selector is .star? (a) an id selector (b) a class selector (c) an element selector
- 4.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the later one (c) neither (d) the shorter one
-
5.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 32px;
}
} (a) Yes (b) No - 6.✍️ Which sign ends each CSS declaration? (a) : (b) ; (c) . (d) ,
-
7.✍️ Which property is set to red in this rule?
#top {
padding: 8px;
font-weight: bold;
font-size: 20px;
color: red;
} (a) text-align (b) font-size (c) color (d) red -
8.✍️ What is the selector in this CSS rule?
.box {
background-color: yellow;
border: 2px solid;
} (a) background-color (b) h2 (c) .box (d) 2px solid - 9.🌈 Which colour of light is strongest in rgb(0, 48, 223)? (a) green (b) red (c) blue
-
10.🖌️ What colour are the letters?
p {
background-color: blue;
color: orange;
text-align: center;
font-size: 16px;
} (a) blue (b) red (c) orange -
11.🎯 Which CSS selector matches this element?
<div class="box" id="intro">Hello</div> (a) .intro (b) div (c) .star (d) #box - 12.True or false: margin is the line round the box. (a) True (b) False
-
13.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 280px;
justify-content: center;
}
Inside are 4 boxes, each 50px wide (no margins). - 14.📦 In the box model, which part is a solid or dotted edge? (a) content (b) margin (c) border (d) padding
- 15.🖌️ Which CSS property picks the font style? (a) background-color (b) font-size (c) font-family (d) color
-
16.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 14px;
}
} (a) No (b) Yes -
17.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 180px;
justify-content: center;
}
Inside are 2 boxes, each 80px wide (no margins). - 18.🎯 Which element does the selector li style? (a) <div> (b) <p id="top"> (c) <li class="big"> (d) <span class="big">
- 19.True or false: h1 is an element selector. (a) True (b) False
-
20.🖌️ What colour are the letters?
h2 {
font-size: 40px;
background-color: blue;
text-align: center;
color: black;
} (a) black (b) yellow (c) blue - 21.🎯 Which element does the selector .red style? (a) <div id="red"> (b) <div class="box"> (c) <div class="red"> (d) <span class="star">
-
22.🖌️ What colour are the letters?
h2 {
color: black;
font-size: 40px;
text-align: right;
background-color: yellow;
} (a) green (b) yellow (c) black - 23.🌈 Which colour of light is strongest in rgb(24, 226, 69)? (a) red (b) green (c) blue
-
24.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 16px;
}
} (a) Yes (b) No -
25.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 230px;
padding: 10px;
border: 5px solid black;
margin: 10px;
} -
26.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
font-weight: bold;
margin: 10px;
} - 27.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
-
28.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 380px;
justify-content: center;
}
Inside are 4 boxes, each 60px wide (no margins). -
29.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 120px;
padding: 15px;
border: 5px solid black;
margin: 15px;
} - 30.What does justify-content: flex-start do? (a) packs boxes at the end (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the start
-
31.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 310px;
justify-content: flex-end;
}
Inside are 3 boxes, each 80px wide (no margins). - 32.🎯 Which element does the selector p style? (a) <li id="intro"> (b) <p class="menu"> (c) <h1> (d) <h2 class="menu">
-
33.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 150px;
padding: 20px;
border: 2px solid black;
margin: 15px;
} - 34.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) red (c) green (d) white
- 35.Which of these does HTML do? (a) reacts to a button click (b) changes the text size (c) rounds box corners (d) puts a picture on a page
- 36.🧩 Which language makes headings and lists? (a) CSS (b) HTML (c) JavaScript
- 37.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
-
38.✍️ What value is given to padding in this rule?
body {
width: 300px;
padding: 8px;
font-style: italic;
color: red;
} (a) bold (b) 2px solid (c) 8px (d) padding -
39.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 10px;
}
} (a) Yes (b) No - 40.🎯 What kind of selector is .big? (a) an element selector (b) a class selector (c) an id selector
Answer key
- white
- 240
- a class selector
- the later one
- Yes
- ;
- color
- .box
- blue
- orange
- div
- False
- 40
- border
- font-family
- No
- 10
- <li class="big">
- True
- black
- <div class="red">
- black
- green
- No
- 280
- 2
- an element selector
- 70
- 190
- packs boxes at the start
- 70
- <p class="menu">
- 224
- blue
- puts a picture on a page
- HTML
- an id selector
- 8px
- Yes
- a class selector
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids