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="red" id="end">Hi</p>
CSS:
.red { color: green; }
p { color: yellow; }
#end { color: purple; } (a) purple (b) red (c) green (d) yellow -
2.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 22px;
}
} - 3.🎯 Which sign starts an id selector? (a) @ (b) & (c) # (d) .
- 4.🌈 In #rrggbb, which colour do the first two digits give? (a) blue (b) green (c) black (d) red
-
5.⚖️ What colour is the text of this element?
<h1 class="star" id="intro">Hi</h1>
CSS:
.star { color: yellow; }
.star { color: orange; } (a) orange (b) black (c) purple (d) yellow - 6.True or false: #main is an element selector. (a) False (b) True
- 7.📱 What does a media query check? (a) the time of day (b) the screen width (c) the battery level (d) the page title
- 8.🌈 Which hex code is red? (a) #ffff00 (b) #ff00ff (c) #000000 (d) #ff0000
- 9.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) neither (c) the later one (d) the first one
- 10.What does text-align do? (a) picks the font style (b) sets the letter colour (c) colours behind the text (d) centres a heading
- 11.🖌️ Which CSS property picks the font style? (a) font-size (b) font-family (c) font-weight (d) color
-
12.🖌️ How big is the text, in px?
h1 {
color: blue;
text-align: right;
background-color: black;
font-size: 40px;
} - 13.🧩 Which language changes the page live? (a) HTML (b) CSS (c) JavaScript
- 14.💪 Which flexbox property picks row or column? (a) align-items (b) flex-direction (c) display: flex (d) justify-content
- 15.True or false: CSS counts down a timer. (a) False (b) True
-
16.✍️ What is the selector in this CSS rule?
p {
font-size: 20px;
font-weight: bold;
margin: 10px;
} (a) .note (b) p (c) font-size (d) bold -
17.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 220px;
justify-content: flex-start;
}
Inside are 2 boxes, each 100px wide (no margins). - 18.True or false: HTML puts a picture on a page. (a) False (b) True
-
19.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 160px;
justify-content: space-between;
}
Inside are 2 boxes, each 60px wide (no margins). - 20.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
-
21.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 20px;
}
} (a) Yes (b) No - 22.💪 Which justify-content value packs boxes at the start? (a) flex-start (b) space-between (c) center (d) flex-end
-
23.⚖️ What colour is the text of this element?
<p class="star" id="main">Hi</p>
CSS:
p { color: blue; }
p { color: purple; } (a) red (b) blue (c) yellow (d) purple -
24.⚖️ What colour is the text of this element?
<p class="big" id="main">Hi</p>
CSS:
#main { color: orange; }
p { color: white; } (a) white (b) orange (c) green (d) red -
25.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 180px;
justify-content: flex-start;
}
Inside are 3 boxes, each 40px wide (no margins). -
26.🎯 Which CSS selector matches this element?
<p class="menu" id="top">Hello</p> (a) p (b) .top (c) #menu (d) .note - 27.🎯 What kind of selector is img? (a) an id selector (b) an element selector (c) a class selector
- 28.🌈 Which colour is #00ffff? (a) red (b) cyan (c) black (d) magenta
- 29.🎨 One CSS file can style how many pages? (a) no pages (b) only one image (c) many pages (d) only one word
-
30.⚖️ What colour is the text of this element?
<h1 class="red" id="main">Hi</h1>
CSS:
h1 { color: orange; }
.red { color: red; } (a) orange (b) blue (c) black (d) red -
31.⚖️ What colour is the text of this element?
<p class="big" id="top">Hi</p>
CSS:
#top { color: black; }
.big { color: purple; } (a) black (b) purple (c) green (d) yellow -
32.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 8px;
}
} (a) No (b) Yes -
33.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 24px;
}
} -
34.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 30px;
}
} (a) Yes (b) No - 35.🎯 Which element does the selector #end style? (a) <span class="end"> (b) <span id="hero"> (c) <span id="end"> (d) <p class="menu">
- 36.Which of these is padding? (a) space outside the border (b) the gap to other boxes (c) the gap round content (d) the text or picture
- 37.✍️ CSS declarations go inside which brackets? (a) { } (b) < > (c) [ ] (d) ( )
- 38.🎯 What kind of selector is .note? (a) a class selector (b) an element selector (c) an id selector
-
39.⚖️ What colour is the text of this element?
<h1 class="menu" id="intro">Hi</h1>
CSS:
.menu { color: orange; }
.menu { color: red; } (a) black (b) blue (c) orange (d) red - 40.🌈 In #00dd00 the green part is the hex number dd. What is it as a normal number?
Answer key
- purple
- 22
- #
- red
- orange
- False
- the screen width
- #ff0000
- the later one
- centres a heading
- font-family
- 40
- JavaScript
- flex-direction
- False
- p
- 20
- True
- 40
- an id selector
- Yes
- flex-start
- purple
- orange
- 60
- p
- an element selector
- cyan
- many pages
- red
- black
- No
- 16
- No
- <span id="end">
- the gap round content
- { }
- a class selector
- red
- 221
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids