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 kind of selector is #main? (a) an id selector (b) an element selector (c) a class selector
-
2.🖌️ What colour is behind the letters?
h2 {
font-size: 20px;
color: green;
text-align: center;
background-color: red;
} (a) green (b) white (c) red -
3.⚖️ What colour is the text of this element?
<p class="note" id="top">Hi</p>
CSS:
p { color: green; }
.note { color: black; } (a) blue (b) green (c) yellow (d) black - 4.True or false: margin is space inside the border. (a) True (b) False
- 5.🌈 Which colour of light is strongest in rgb(46, 190, 41)? (a) green (b) red (c) blue
- 6.🌈 Which hex code is red? (a) #00ff00 (b) #00ffff (c) #ffffff (d) #ff0000
- 7.🎯 Which element does the selector #end style? (a) <div id="hero"> (b) <div class="end"> (c) <span class="big"> (d) <div id="end">
-
8.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-size: 20px;
border: 2px solid;
background-color: yellow;
text-align: center;
} -
9.✍️ How many declarations (property: value pairs) are in this rule?
.note {
width: 300px;
border: 2px solid;
padding: 8px;
} - 10.📱 Which tag helps phones show a page at the right size? (a) the viewport meta tag (b) the title tag (c) the hr tag (d) the br tag
-
11.✍️ How many declarations (property: value pairs) are in this rule?
li {
font-size: 20px;
width: 300px;
} -
12.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 160px;
justify-content: space-between;
}
Inside are 2 boxes, each 40px wide (no margins). -
13.⚖️ What colour is the text of this element?
<p class="menu" id="main">Hi</p>
CSS:
p { color: yellow; }
p { color: black; } (a) black (b) yellow (c) orange (d) purple - 14.🖌️ Which CSS property centres a heading? (a) text-align (b) color (c) font-family (d) font-weight
-
15.⚖️ What colour is the text of this element?
<h1 class="star" id="end">Hi</h1>
CSS:
#end { color: orange; }
#end { color: white; } (a) white (b) red (c) orange (d) blue - 16.✍️ Which sign goes between a property and its value? (a) = (b) : (c) ; (d) -
- 17.🌈 In #000046 the blue part is the hex number 46. What is it as a normal number?
- 18.🌈 In #rrggbb, which colour do the first two digits give? (a) black (b) blue (c) green (d) red
-
19.🖌️ How big is the text, in px?
h2 {
text-align: right;
font-size: 20px;
color: orange;
background-color: red;
} - 20.🌈 Which colour is rgb(0, 255, 255)? (a) red (b) black (c) magenta (d) cyan
- 21.📦 In the box model, which part is the gap round content? (a) content (b) margin (c) border (d) padding
- 22.🎯 Which element does the selector span style? (a) <p> (b) <h2 id="hero"> (c) <h1 class="note"> (d) <span class="note">
-
23.⚖️ What colour is the text of this element?
<h1 class="box" id="top">Hi</h1>
CSS:
#top { color: white; }
h1 { color: black; }
.box { color: green; } (a) green (b) white (c) black (d) red - 24.🧩 Which language counts down a timer? (a) HTML (b) JavaScript (c) CSS
- 25.What does text-align do? (a) picks the font style (b) makes letters bigger (c) colours behind the text (d) centres a heading
-
26.✍️ Which property is set to 10px in this rule?
#top {
margin: 10px;
width: 300px;
} (a) font-weight (b) margin (c) 10px (d) padding - 27.True or false: the content is the gap round content. (a) False (b) True
-
28.⚖️ What colour is the text of this element?
<h2 class="star" id="intro">Hi</h2>
CSS:
h2 { color: red; }
.star { color: yellow; } (a) blue (b) yellow (c) green (d) red - 29.Which of these is margin? (a) space inside the border (b) a solid or dotted edge (c) the gap to other boxes (d) the text or picture
- 30.🌈 Which hex code is bright green? (a) #ffffff (b) #00ffff (c) #00ff00 (d) #ff0000
-
31.✍️ Which property is set to 300px in this rule?
p {
color: red;
width: 300px;
} (a) 300px (b) font-style (c) width (d) color - 32.✍️ How does a CSS comment start? (a) // (b) <!-- (c) /* (d) #
- 33.🌈 Which hex code is magenta? (a) #ff00ff (b) #ff0000 (c) #0000ff (d) #ffffff
- 34.🌈 Which colour of light is strongest in rgb(177, 7, 8)? (a) red (b) green (c) blue
-
35.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 260px;
justify-content: flex-start;
}
Inside are 4 boxes, each 60px wide (no margins). -
36.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 60px;
padding: 5px;
border: 5px solid black;
margin: 10px;
} - 37.🎯 Which element does the selector .big style? (a) <p class="box"> (b) <span id="big"> (c) <span class="red"> (d) <span class="big">
- 38.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
-
39.✍️ How many declarations (property: value pairs) are in this rule?
.box {
color: red;
padding: 8px;
} -
40.✍️ What is the selector in this CSS rule?
p {
font-weight: bold;
color: red;
background-color: yellow;
} (a) font-weight (b) .note (c) red (d) p
Answer key
- an id selector
- red
- black
- False
- green
- #ff0000
- <div id="end">
- 4
- 3
- the viewport meta tag
- 2
- 80
- black
- text-align
- white
- :
- 70
- red
- 20
- cyan
- padding
- <span class="note">
- white
- JavaScript
- centres a heading
- margin
- False
- yellow
- the gap to other boxes
- #00ff00
- width
- /*
- #ff00ff
- red
- 20
- 100
- <span class="big">
- equal gaps, none at ends
- 2
- p
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids