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 much space across (px) does this box take in all, margin included?
.box {
width: 260px;
padding: 20px;
border: 2px solid black;
margin: 10px;
} -
2.⚖️ What colour is the text of this element?
<p class="big" id="end">Hi</p>
CSS:
#end { color: green; }
#end { color: black; } (a) green (b) red (c) black (d) orange - 3.✍️ In color: blue; which part is the value? (a) ; (b) blue (c) color (d) :
- 4.💪 Which flexbox property turns on flexbox? (a) justify-content (b) gap (c) flex-direction (d) display: flex
-
5.🖌️ What colour is behind the letters?
p {
background-color: black;
text-align: center;
font-size: 28px;
color: yellow;
} (a) yellow (b) red (c) black - 6.What does color do? (a) colours behind the text (b) sets the letter colour (c) makes the text bold (d) centres a heading
- 7.🌈 In #rrggbb, which colour do the first two digits give? (a) blue (b) red (c) green (d) black
- 8.💪 Which flexbox property lines boxes up across? (a) flex-direction (b) align-items (c) justify-content (d) display: flex
- 9.✍️ Which sign ends each CSS declaration? (a) . (b) ; (c) , (d) :
-
10.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 28px;
}
} (a) Yes (b) No - 11.🎯 Which element does the selector p style? (a) <h1> (b) <li id="hero"> (c) <p class="star"> (d) <h2 class="star">
-
12.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 290px;
padding: 5px;
border: 4px solid black;
margin: 0px;
} - 13.🎯 Can many elements share the same class? (a) No (b) Yes
- 14.🌈 Which hex code is cyan? (a) #00ff00 (b) #000000 (c) #ffff00 (d) #00ffff
- 15.🌈 In #008c00 the green part is the hex number 8c. What is it as a normal number?
- 16.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the shorter one (c) neither (d) the later one
- 17.🎯 What kind of selector is li? (a) an id selector (b) an element selector (c) a class selector
- 18.Which of these does CSS do? (a) shows a pop-up message (b) changes the page live (c) gives the page structure (d) lays out the page
- 19.📱 Responsive design means a page ___. (a) has no pictures (b) fits every screen (c) is only for laptops (d) never changes
- 20.🎯 What kind of selector is .menu? (a) an element selector (b) a class selector (c) an id selector
- 21.🎯 Which sign starts an id selector? (a) . (b) @ (c) & (d) #
- 22.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
-
23.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 130px;
padding: 10px;
border: 3px solid black;
margin: 0px;
} - 24.Which of these is margin? (a) the line round the box (b) space inside the border (c) the gap to other boxes (d) the gap round content
-
25.⚖️ What colour is the text of this element?
<h2 class="red" id="logo">Hi</h2>
CSS:
.red { color: white; }
.red { color: red; } (a) white (b) blue (c) red (d) black - 26.🌈 Hex digits go 0 to 9, then A to which letter? (a) G (b) F (c) J (d) Z
- 27.🔍 Which is the odd one out? (a) checks a quiz answer (b) shows a pop-up message (c) changes the text size (d) changes the page live
- 28.🌈 Which hex code is blue? (a) #00ffff (b) #00ff00 (c) #0000ff (d) #000000
- 29.True or false: the border is the line round the box. (a) False (b) True
-
30.⚖️ What colour is the text of this element?
<p class="menu" id="top">Hi</p>
CSS:
#top { color: blue; }
p { color: yellow; } (a) orange (b) blue (c) red (d) yellow - 31.📱 What does a media query check? (a) the page title (b) the time of day (c) the screen width (d) the battery level
- 32.📦 In the box model, which part is the gap to other boxes? (a) content (b) margin (c) padding (d) border
-
33.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 210px;
padding: 25px;
border: 4px solid black;
margin: 0px;
} - 34.True or false: JavaScript reacts to a button click. (a) True (b) False
- 35.🌈 Which colour is rgb(0, 255, 255)? (a) magenta (b) cyan (c) white (d) yellow
- 36.📦 In the box model, which part is space outside the border? (a) border (b) margin (c) content (d) padding
- 37.🖌️ Which CSS property colours behind the text? (a) text-align (b) color (c) background-color (d) font-size
- 38.True or false: #top is an id selector. (a) True (b) False
-
39.⚖️ What colour is the text of this element?
<p class="big" id="logo">Hi</p>
CSS:
p { color: green; }
p { color: purple; } (a) blue (b) green (c) purple (d) white -
40.🖌️ What colour are the letters?
li {
color: yellow;
font-size: 24px;
background-color: red;
text-align: left;
} (a) black (b) yellow (c) red
Answer key
- 324
- black
- blue
- display: flex
- black
- sets the letter colour
- red
- align-items
- ;
- No
- <p class="star">
- 308
- Yes
- #00ffff
- 140
- the later one
- an element selector
- lays out the page
- fits every screen
- a class selector
- #
- an element selector
- 156
- the gap to other boxes
- red
- F
- changes the text size
- #0000ff
- True
- blue
- the screen width
- margin
- 268
- True
- cyan
- margin
- background-color
- True
- purple
- yellow
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids