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.📦 In the box model, which part is space inside the border? (a) content (b) margin (c) padding (d) border
-
2.✍️ Which property is set to 300px in this rule?
.box {
width: 300px;
text-align: center;
padding: 8px;
} (a) color (b) 300px (c) font-style (d) width - 3.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) black (c) red (d) blue
- 4.⚖️ 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
- 5.True or false: margin is space outside the border. (a) False (b) True
-
6.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 18px;
}
} - 7.💪 Which justify-content value packs boxes at the start? (a) center (b) flex-end (c) space-between (d) flex-start
-
8.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 460px;
justify-content: flex-end;
}
Inside are 4 boxes, each 100px wide (no margins). -
9.✍️ What is the selector in this CSS rule?
p {
text-align: center;
background-color: yellow;
border: 2px solid;
font-size: 20px;
} (a) yellow (b) .note (c) text-align (d) p -
10.🖌️ What colour is behind the letters?
h1 {
text-align: center;
background-color: blue;
font-size: 24px;
color: white;
} (a) purple (b) white (c) blue -
11.✍️ What value is given to color in this rule?
.note {
font-weight: bold;
color: red;
} (a) color (b) 20px (c) red (d) center - 12.✍️ Which sign ends each CSS declaration? (a) : (b) ; (c) . (d) ,
- 13.🎨 A CSS file usually ends with which extension? (a) .png (b) .js (c) .html (d) .css
- 14.🎯 Which element does the selector h1 style? (a) <h2> (b) <li class="box"> (c) <div id="intro"> (d) <h1 class="box">
-
15.⚖️ What colour is the text of this element?
<h2 class="box" id="hero">Hi</h2>
CSS:
h2 { color: orange; }
#hero { color: black; }
.box { color: green; } (a) green (b) orange (c) black (d) blue - 16.🎯 How many elements on a page should have the same id? (a) 1 (b) 5 (c) 2 (d) any number
- 17.🎨 Which tag connects an outside CSS file? (a) <img> (b) <css> (c) <link> (d) <a>
- 18.🎨 One CSS file can style how many pages? (a) many pages (b) only one word (c) no pages (d) only one image
- 19.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
- 20.🌈 In #070000 the red part is the hex number 07. What is it as a normal number?
- 21.💪 Which justify-content value equal gaps, none at ends? (a) space-between (b) flex-end (c) flex-start (d) center
-
22.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 20px;
}
} -
23.🎯 Which CSS selector matches this element?
<h2 class="box" id="main">Hello</h2> (a) #logo (b) h2 (c) .main (d) li - 24.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) exactly 100px (c) 800px or wider (d) 800px or narrower
-
25.🖌️ What colour is behind the letters?
h2 {
font-size: 36px;
color: yellow;
text-align: left;
background-color: red;
} (a) red (b) yellow (c) blue - 26.🔍 Which is the odd one out? (a) gives the page structure (b) changes the text size (c) makes headings and lists (d) makes a link
-
27.⚖️ What colour is the text of this element?
<p class="note" id="logo">Hi</p>
CSS:
#logo { color: yellow; }
.note { color: green; }
p { color: purple; } (a) yellow (b) red (c) green (d) purple - 28.True or false: HTML makes a form box. (a) True (b) False
- 29.🌈 Which colour is rgb(0, 255, 0)? (a) bright green (b) black (c) red (d) cyan
- 30.🌈 Which colour of light is strongest in rgb(116, 237, 108)? (a) blue (b) green (c) red
- 31.🌈 Which colour is #ff00ff? (a) bright green (b) blue (c) magenta (d) red
-
32.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 420px;
justify-content: flex-end;
}
Inside are 4 boxes, each 100px wide (no margins). -
33.⚖️ What colour is the text of this element?
<p class="menu" id="top">Hi</p>
CSS:
#top { color: red; }
#top { color: blue; } (a) black (b) green (c) blue (d) red -
34.⚖️ What colour is the text of this element?
<h1 class="big" id="top">Hi</h1>
CSS:
.big { color: red; }
h1 { color: purple; }
#top { color: black; } (a) red (b) black (c) blue (d) purple - 35.🌈 In #aa0000 the red part is the hex number aa. What is it as a normal number?
-
36.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 8px;
}
} -
37.⚖️ What colour is the text of this element?
<h1 class="menu" id="top">Hi</h1>
CSS:
h1 { color: red; }
h1 { color: blue; } (a) orange (b) blue (c) red (d) yellow - 38.🌈 Which hex code is magenta? (a) #00ff00 (b) #00ffff (c) #ff00ff (d) #000000
- 39.📱 What does a media query check? (a) the battery level (b) the screen width (c) the page title (d) the time of day
-
40.🖌️ What colour is behind the letters?
h2 {
background-color: green;
text-align: left;
font-size: 24px;
color: red;
} (a) red (b) blue (c) green
Answer key
- padding
- width
- red
- the later one
- True
- 18
- flex-start
- 60
- p
- blue
- red
- ;
- .css
- <h1 class="box">
- black
- 1
- <link>
- many pages
- an element selector
- 7
- space-between
- 16
- h2
- 800px or wider
- red
- changes the text size
- yellow
- True
- bright green
- green
- magenta
- 20
- blue
- black
- 170
- 8
- blue
- #ff00ff
- the screen width
- green
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids