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 language changes the page live? (a) CSS (b) HTML (c) JavaScript
-
2.🖌️ What colour is behind the letters?
h1 {
text-align: center;
background-color: white;
font-size: 12px;
color: orange;
} (a) white (b) red (c) orange - 3.💪 Which flexbox property spaces boxes along a row? (a) display: flex (b) align-items (c) justify-content (d) gap
- 4.What does justify-content: center do? (a) packs boxes at the end (b) packs boxes at the start (c) puts boxes in the middle (d) equal gaps, none at ends
- 5.🌈 Which colour is #ff00ff? (a) magenta (b) bright green (c) yellow (d) red
- 6.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the first one (c) neither (d) the shorter one
- 7.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
- 8.🎨 One CSS file can style how many pages? (a) only one word (b) only one image (c) many pages (d) no pages
- 9.What does font-size do? (a) makes letters bigger (b) sets the letter colour (c) colours behind the text (d) picks the font style
-
10.🖌️ What colour are the letters?
h2 {
text-align: left;
color: purple;
font-size: 24px;
background-color: green;
} (a) green (b) blue (c) purple - 11.📱 max-width: 600px applies when the screen is ___. (a) 600px or narrower (b) turned off (c) 600px or wider (d) exactly 1000px
-
12.✍️ What is the selector in this CSS rule?
p {
color: red;
font-style: italic;
} (a) italic (b) color (c) p (d) .note - 13.True or false: HTML gives the page structure. (a) True (b) False
- 14.🌈 Hex digits go 0 to 9, then A to which letter? (a) J (b) G (c) Z (d) F
- 15.🎯 What kind of selector is img? (a) an id selector (b) a class selector (c) an element selector
-
16.🖌️ How big is the text, in px?
p {
text-align: right;
background-color: black;
color: yellow;
font-size: 12px;
} - 17.🎯 Which element does the selector .note style? (a) <li class="red"> (b) <h2 class="big"> (c) <h2 id="note"> (d) <h2 class="note">
- 18.📦 In the box model, which part is the gap round content? (a) border (b) content (c) margin (d) padding
-
19.⚖️ What colour is the text of this element?
<h1 class="star" id="intro">Hi</h1>
CSS:
.star { color: green; }
.star { color: red; } (a) green (b) yellow (c) blue (d) red - 20.🎯 What kind of selector is #main? (a) a class selector (b) an element selector (c) an id selector
- 21.Which of these does JavaScript do? (a) makes a form box (b) lays out the page (c) changes the page live (d) makes a link
- 22.📦 In the box model, which part is space outside the border? (a) content (b) margin (c) border (d) padding
- 23.🌈 What is the biggest number one colour can have in rgb()? (a) 255 (b) 1000 (c) 99 (d) 100
-
24.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 22px;
}
} - 25.True or false: HTML shows a pop-up message. (a) False (b) True
-
26.✍️ How many declarations (property: value pairs) are in this rule?
#top {
padding: 8px;
} -
27.🖌️ What colour is behind the letters?
h2 {
text-align: right;
background-color: black;
font-size: 40px;
color: purple;
} (a) red (b) black (c) purple -
28.🎯 Which CSS selector matches this element?
<h2 class="menu" id="logo">Hello</h2> (a) #menu (b) .menu (c) .logo (d) #end - 29.🌈 Which colour is #ffffff? (a) black (b) blue (c) cyan (d) white
-
30.🖌️ What colour are the letters?
h1 {
text-align: left;
color: white;
font-size: 32px;
background-color: purple;
} (a) black (b) purple (c) white - 31.What does background-color do? (a) colours behind the text (b) picks the font style (c) centres a heading (d) sets the letter colour
-
32.✍️ What value is given to background-color in this rule?
body {
background-color: yellow;
border: 2px solid;
} (a) 10px (b) yellow (c) 8px (d) background-color -
33.✍️ What is the selector in this CSS rule?
p {
font-size: 20px;
font-style: italic;
background-color: yellow;
} (a) italic (b) p (c) font-size (d) .note - 34.🌈 Which colour is rgb(0, 255, 0)? (a) blue (b) red (c) bright green (d) white
-
35.✍️ What value is given to background-color in this rule?
li {
margin: 10px;
background-color: yellow;
} (a) background-color (b) yellow (c) 10px (d) 8px -
36.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 190px;
padding: 15px;
border: 4px solid black;
margin: 10px;
} - 37.🖌️ Which CSS property centres a heading? (a) background-color (b) text-align (c) font-size (d) font-weight
-
38.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 600px) {
p {
font-size: 18px;
}
} - 39.True or false: #main is an element selector. (a) True (b) False
-
40.✍️ What is the selector in this CSS rule?
#top {
font-weight: bold;
padding: 8px;
} (a) li (b) font-weight (c) 8px (d) #top
Answer key
- JavaScript
- white
- justify-content
- puts boxes in the middle
- magenta
- the later one
- an id selector
- many pages
- makes letters bigger
- purple
- 600px or narrower
- p
- True
- F
- an element selector
- 12
- <h2 class="note">
- padding
- red
- an id selector
- changes the page live
- margin
- 255
- 22
- False
- 1
- black
- .menu
- white
- white
- colours behind the text
- yellow
- p
- bright green
- yellow
- 228
- text-align
- 16
- False
- #top
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids