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="box" id="end">Hi</p>
CSS:
p { color: yellow; }
#end { color: white; } (a) blue (b) white (c) orange (d) yellow - 2.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the title tag (c) the br tag (d) the viewport meta tag
- 3.True or false: .star is a class selector. (a) True (b) False
-
4.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 14px;
}
} (a) No (b) Yes -
5.⚖️ What colour is the text of this element?
<h2 class="star" id="top">Hi</h2>
CSS:
h2 { color: yellow; }
h2 { color: red; } (a) red (b) white (c) yellow (d) orange -
6.✍️ Which property is set to 8px in this rule?
.box {
text-align: center;
padding: 8px;
background-color: yellow;
} (a) 8px (b) padding (c) border (d) font-weight - 7.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the first one (c) the later one (d) the shorter one
-
8.⚖️ What colour is the text of this element?
<p class="star" id="logo">Hi</p>
CSS:
#logo { color: purple; }
p { color: orange; }
.star { color: white; } (a) orange (b) yellow (c) purple (d) white - 9.True or false: margin is a solid or dotted edge. (a) False (b) True
-
10.✍️ Which property is set to 300px in this rule?
li {
text-align: center;
border: 2px solid;
width: 300px;
} (a) 300px (b) color (c) font-style (d) width -
11.🖌️ How big is the text, in px?
h2 {
background-color: blue;
text-align: right;
font-size: 36px;
color: red;
} -
12.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 100px;
padding: 10px;
border: 1px solid black;
margin: 20px;
} - 13.True or false: .note is a class selector. (a) False (b) True
-
14.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 260px;
justify-content: flex-start;
}
Inside are 3 boxes, each 60px wide (no margins). - 15.True or false: HTML sets colours and fonts. (a) False (b) True
- 16.🎯 Which element does the selector p style? (a) <p class="big"> (b) <h1> (c) <h2 class="big"> (d) <li id="top">
-
17.🎯 Which CSS selector matches this element?
<p class="big" id="main">Hello</p> (a) #big (b) h1 (c) .big (d) .main - 18.🎯 What kind of selector is .big? (a) a class selector (b) an id selector (c) an element selector
- 19.True or false: the border is the text or picture. (a) False (b) True
-
20.⚖️ What colour is the text of this element?
<h2 class="note" id="top">Hi</h2>
CSS:
#top { color: yellow; }
#top { color: white; } (a) white (b) yellow (c) purple (d) black - 21.🌈 Which colour of light is strongest in rgb(166, 124, 13)? (a) green (b) red (c) blue
- 22.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) turned off (c) 600px or narrower (d) 600px or wider
- 23.🧩 Which language makes headings and lists? (a) HTML (b) JavaScript (c) CSS
-
24.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 250px;
justify-content: flex-start;
}
Inside are 4 boxes, each 60px wide (no margins). - 25.🌈 Which colour is rgb(0, 0, 0)? (a) yellow (b) black (c) blue (d) cyan
-
26.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 170px;
justify-content: space-between;
}
Inside are 2 boxes, each 80px wide (no margins). - 27.What does justify-content: space-between do? (a) packs boxes at the end (b) puts boxes in the middle (c) packs boxes at the start (d) equal gaps, none at ends
- 28.🎯 What kind of selector is #hero? (a) an element selector (b) an id selector (c) a class selector
-
29.⚖️ What colour is the text of this element?
<h1 class="box" id="hero">Hi</h1>
CSS:
.box { color: black; }
h1 { color: blue; } (a) green (b) blue (c) orange (d) black -
30.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: flex-end;
}
Inside are 2 boxes, each 100px wide (no margins). -
31.✍️ How many declarations (property: value pairs) are in this rule?
p {
background-color: yellow;
font-size: 20px;
border: 2px solid;
} -
32.🖌️ What colour are the letters?
p {
color: red;
text-align: center;
font-size: 32px;
background-color: black;
} (a) black (b) orange (c) red - 33.🎯 What kind of selector is .note? (a) a class selector (b) an id selector (c) an element selector
-
34.✍️ Which property is set to 20px in this rule?
li {
font-size: 20px;
border: 2px solid;
} (a) text-align (b) font-size (c) background-color (d) 20px - 35.True or false: #hero is an id selector. (a) False (b) True
- 36.What does justify-content: flex-start do? (a) equal gaps, none at ends (b) packs boxes at the start (c) puts boxes in the middle (d) packs boxes at the end
- 37.True or false: HTML checks a quiz answer. (a) False (b) True
- 38.What does justify-content: flex-end do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the start (d) packs boxes at the end
- 39.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) justify-content (c) gap (d) display: flex
-
40.✍️ What is the selector in this CSS rule?
p {
font-weight: bold;
text-align: center;
background-color: yellow;
} (a) center (b) font-weight (c) .note (d) p
Answer key
- white
- the viewport meta tag
- True
- Yes
- red
- padding
- the later one
- purple
- False
- width
- 36
- 162
- True
- 80
- False
- <p class="big">
- .big
- a class selector
- False
- white
- red
- 600px or narrower
- HTML
- 10
- black
- 10
- equal gaps, none at ends
- an id selector
- black
- 60
- 3
- red
- a class selector
- font-size
- True
- packs boxes at the start
- False
- packs boxes at the end
- display: flex
- p
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids