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 wide (px) is each gap between two boxes?
.row {
display: flex;
width: 410px;
justify-content: space-between;
}
Inside are 4 boxes, each 50px wide (no margins). - 2.📱 Which tag helps phones show a page at the right size? (a) the br tag (b) the title tag (c) the viewport meta tag (d) the hr tag
-
3.🎯 Which CSS selector matches this element?
<p class="box" id="logo">Hello</p> (a) .logo (b) p (c) #box (d) #end - 4.🎯 Which element does the selector p style? (a) <p class="note"> (b) <h1> (c) <h2 class="note"> (d) <li id="logo">
-
5.🖌️ How big is the text, in px?
h2 {
text-align: left;
background-color: yellow;
font-size: 40px;
color: white;
} -
6.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 270px;
justify-content: flex-end;
}
Inside are 4 boxes, each 50px wide (no margins). -
7.✍️ What value is given to font-style in this rule?
.box {
padding: 8px;
border: 2px solid;
font-style: italic;
font-weight: bold;
} (a) 20px (b) font-style (c) red (d) italic - 8.True or false: #top is an id selector. (a) False (b) True
- 9.🌈 Which colour is #00ffff? (a) cyan (b) black (c) blue (d) white
- 10.📦 In the box model, which part is the line round the box? (a) margin (b) padding (c) border (d) content
-
11.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
padding: 8px;
} -
12.⚖️ What colour is the text of this element?
<h1 class="menu" id="intro">Hi</h1>
CSS:
h1 { color: green; }
.menu { color: orange; }
#intro { color: black; } (a) yellow (b) orange (c) black (d) green - 13.Which of these does JavaScript do? (a) changes the text size (b) sets colours and fonts (c) checks a quiz answer (d) gives the page structure
-
14.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 60px;
padding: 25px;
border: 2px solid black;
margin: 5px;
} - 15.🎨 A CSS file usually ends with which extension? (a) .png (b) .css (c) .js (d) .html
- 16.💪 Which flexbox property turns on flexbox? (a) justify-content (b) flex-direction (c) display: flex (d) gap
- 17.🎯 What kind of selector is .big? (a) a class selector (b) an id selector (c) an element selector
- 18.🎯 Which element does the selector #main style? (a) <div class="star"> (b) <li id="main"> (c) <li id="logo"> (d) <li class="main">
-
19.🖌️ What colour are the letters?
h1 {
background-color: white;
color: blue;
font-size: 36px;
text-align: left;
} (a) yellow (b) white (c) blue - 20.🌈 Which hex code is black? (a) #ffff00 (b) #ffffff (c) #000000 (d) #0000ff
- 21.🎯 Which element does the selector li style? (a) <div> (b) <li class="note"> (c) <span class="note"> (d) <p id="main">
- 22.🎯 Can many elements share the same class? (a) Yes (b) No
- 23.Which of these does HTML do? (a) counts down a timer (b) shows a pop-up message (c) rounds box corners (d) gives the page structure
-
24.🎯 Which CSS selector matches this element?
<p class="note" id="logo">Hello</p> (a) #note (b) h1 (c) .logo (d) .note -
25.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 170px;
padding: 10px;
border: 1px solid black;
margin: 5px;
} -
26.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 150px;
padding: 20px;
border: 3px solid black;
margin: 0px;
} -
27.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 20px;
}
} (a) Yes (b) No - 28.Which of these does CSS do? (a) changes the page live (b) counts down a timer (c) sets colours and fonts (d) puts a picture on a page
- 29.🌈 Which colour is rgb(0, 0, 0)? (a) red (b) cyan (c) bright green (d) black
- 30.✍️ How does a CSS comment start? (a) # (b) // (c) <!-- (d) /*
- 31.🌈 In #rrggbb, which colour do the last two digits give? (a) white (b) green (c) red (d) blue
- 32.🌈 Which hex code is red? (a) #00ff00 (b) #000000 (c) #ff0000 (d) #0000ff
- 33.What does justify-content: space-between do? (a) packs boxes at the start (b) equal gaps, none at ends (c) packs boxes at the end (d) puts boxes in the middle
-
34.⚖️ What colour is the text of this element?
<p class="red" id="hero">Hi</p>
CSS:
#hero { color: red; }
#hero { color: yellow; } (a) red (b) black (c) yellow (d) blue - 35.🌈 Which colour of light is strongest in rgb(159, 62, 36)? (a) red (b) blue (c) green
-
36.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-style: italic;
font-size: 20px;
border: 2px solid;
} - 37.Which of these is the border? (a) space outside the border (b) the line round the box (c) space inside the border (d) the gap round content
-
38.⚖️ What colour is the text of this element?
<h1 class="big" id="hero">Hi</h1>
CSS:
h1 { color: white; }
h1 { color: orange; } (a) white (b) orange (c) green (d) blue - 39.What does justify-content: flex-start do? (a) packs boxes at the start (b) packs boxes at the end (c) equal gaps, none at ends (d) puts boxes in the middle
-
40.✍️ How many declarations (property: value pairs) are in this rule?
li {
font-size: 20px;
width: 300px;
}
Answer key
- 70
- the viewport meta tag
- p
- <p class="note">
- 40
- 70
- italic
- True
- cyan
- border
- 1
- black
- checks a quiz answer
- 124
- .css
- display: flex
- a class selector
- <li id="main">
- blue
- #000000
- <li class="note">
- Yes
- gives the page structure
- .note
- 202
- 196
- Yes
- sets colours and fonts
- black
- /*
- blue
- #ff0000
- equal gaps, none at ends
- yellow
- red
- 3
- the line round the box
- orange
- packs boxes at the start
- 2
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids