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 wide (px) is each gap between two boxes?
.row {
display: flex;
width: 320px;
justify-content: space-between;
}
Inside are 3 boxes, each 100px wide (no margins). - 2.🌈 Which colour is rgb(255, 0, 0)? (a) white (b) red (c) black (d) blue
-
3.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 2 boxes, each 80px wide (no margins). - 4.Which of these does JavaScript do? (a) makes a form box (b) sets colours and fonts (c) shows a pop-up message (d) gives the page structure
- 5.🎯 Which element does the selector div style? (a) <h1 id="main"> (b) <p class="big"> (c) <span> (d) <div class="big">
- 6.🌈 Which colour is #00ff00? (a) blue (b) white (c) bright green (d) black
- 7.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the shorter one (c) neither (d) the first one
- 8.True or false: JavaScript makes a form box. (a) False (b) True
-
9.⚖️ What colour is the text of this element?
<p class="menu" id="intro">Hi</p>
CSS:
p { color: orange; }
#intro { color: white; } (a) orange (b) green (c) red (d) white - 10.🎨 Which tag connects an outside CSS file? (a) <img> (b) <link> (c) <css> (d) <a>
- 11.🌈 Which colour is #00ffff? (a) white (b) red (c) cyan (d) blue
- 12.💪 Which flexbox property spaces boxes along a row? (a) gap (b) display: flex (c) justify-content (d) align-items
-
13.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 480px) {
p {
font-size: 14px;
}
} (a) Yes (b) No -
14.🖌️ What colour is behind the letters?
h2 {
font-size: 40px;
background-color: yellow;
text-align: left;
color: green;
} (a) white (b) green (c) yellow -
15.⚖️ What colour is the text of this element?
<h1 class="star" id="main">Hi</h1>
CSS:
#main { color: yellow; }
#main { color: purple; } (a) yellow (b) blue (c) white (d) purple - 16.True or false: .big is an id selector. (a) True (b) False
- 17.🎯 How many elements on a page should have the same id? (a) 2 (b) 1 (c) 5 (d) any number
-
18.✍️ How many declarations (property: value pairs) are in this rule?
#top {
font-size: 20px;
} - 19.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
-
20.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 16px;
}
} -
21.✍️ What value is given to text-align in this rule?
li {
text-align: center;
color: red;
} (a) text-align (b) center (c) yellow (d) 10px - 22.Which of these is margin? (a) a solid or dotted edge (b) space inside the border (c) the gap to other boxes (d) the gap round content
- 23.🌈 Which colour of light is strongest in rgb(115, 86, 233)? (a) green (b) blue (c) red
- 24.🌈 What is the biggest number one colour can have in rgb()? (a) 255 (b) 99 (c) 1000 (d) 100
- 25.🧩 Which language adds space around boxes? (a) HTML (b) JavaScript (c) CSS
- 26.🎯 Which element does the selector h1 style? (a) <li class="note"> (b) <h2> (c) <div id="top"> (d) <h1 class="note">
-
27.🖌️ How big is the text, in px?
li {
text-align: center;
background-color: blue;
color: green;
font-size: 12px;
} -
28.🖌️ How big is the text, in px?
li {
background-color: purple;
font-size: 36px;
text-align: right;
color: black;
} - 29.🎯 Which sign starts a class selector? (a) & (b) @ (c) . (d) #
-
30.🎯 Which CSS selector matches this element?
<p class="box" id="intro">Hello</p> (a) #main (b) .star (c) p (d) .intro -
31.🖌️ What colour are the letters?
h1 {
text-align: right;
color: black;
font-size: 28px;
background-color: purple;
} (a) black (b) yellow (c) purple -
32.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 8px;
}
} (a) No (b) Yes -
33.🖌️ What colour are the letters?
h2 {
font-size: 36px;
color: green;
text-align: left;
background-color: purple;
} (a) red (b) purple (c) green - 34.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
- 35.🎨 One CSS file can style how many pages? (a) only one image (b) no pages (c) many pages (d) only one word
-
36.🖌️ How big is the text, in px?
h2 {
background-color: purple;
text-align: right;
font-size: 16px;
color: blue;
} -
37.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 140px;
padding: 10px;
border: 4px solid black;
margin: 10px;
} -
38.✍️ What value is given to border in this rule?
li {
font-style: italic;
margin: 10px;
border: 2px solid;
} (a) 300px (b) border (c) 2px solid (d) italic - 39.💪 Which flexbox property sets space between boxes? (a) align-items (b) display: flex (c) flex-direction (d) gap
-
40.✍️ What value is given to font-size in this rule?
#top {
margin: 10px;
padding: 8px;
font-size: 20px;
} (a) yellow (b) center (c) font-size (d) 20px
Answer key
- 10
- red
- 50
- shows a pop-up message
- <div class="big">
- bright green
- the later one
- False
- white
- <link>
- cyan
- justify-content
- No
- yellow
- purple
- False
- 1
- 1
- an element selector
- 12
- center
- the gap to other boxes
- blue
- 255
- CSS
- <h1 class="note">
- 12
- 36
- .
- p
- black
- No
- green
- an id selector
- many pages
- 16
- 188
- 2px solid
- gap
- 20px
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids