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 tag connects an outside CSS file? (a) <link> (b) <css> (c) <a> (d) <img>
- 2.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
- 3.What does background-color do? (a) makes the text bold (b) centres a heading (c) picks the font style (d) colours behind the text
- 4.🌈 Which colour is rgb(0, 255, 255)? (a) blue (b) cyan (c) white (d) black
-
5.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 3 boxes, each 80px wide (no margins). - 6.🎨 Which tag holds CSS inside the head? (a) <script> (b) <body> (c) <css> (d) <style>
- 7.🎯 What kind of selector is #top? (a) an element selector (b) a class selector (c) an id selector
-
8.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 30px;
}
} (a) Yes (b) No - 9.🌈 Which colour is rgb(255, 255, 255)? (a) black (b) white (c) red (d) blue
- 10.🔍 Which is the odd one out? (a) shows a pop-up message (b) changes the page live (c) counts down a timer (d) makes a link
- 11.🎯 What kind of selector is #hero? (a) a class selector (b) an element selector (c) an id selector
- 12.What does justify-content: flex-end 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
- 13.📦 In the box model, which part is the text or picture? (a) border (b) margin (c) padding (d) content
-
14.⚖️ What colour is the text of this element?
<h1 class="big" id="main">Hi</h1>
CSS:
.big { color: white; }
.big { color: blue; } (a) purple (b) white (c) yellow (d) blue - 15.📱 What does a media query check? (a) the time of day (b) the screen width (c) the page title (d) the battery level
- 16.What does font-weight do? (a) makes the text bold (b) sets the letter colour (c) colours behind the text (d) centres a heading
- 17.🌈 Which colour is rgb(0, 0, 0)? (a) bright green (b) black (c) yellow (d) magenta
-
18.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 240px;
justify-content: flex-start;
}
Inside are 3 boxes, each 60px wide (no margins). -
19.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 50px;
padding: 5px;
border: 2px solid black;
margin: 5px;
} - 20.🎯 Can many elements share the same class? (a) No (b) Yes
-
21.⚖️ What colour is the text of this element?
<h1 class="box" id="main">Hi</h1>
CSS:
.box { color: blue; }
#main { color: orange; }
h1 { color: black; } (a) black (b) yellow (c) blue (d) orange - 22.True or false: HTML makes headings and lists. (a) True (b) False
- 23.🌈 In #rrggbb, which colour do the first two digits give? (a) black (b) blue (c) green (d) red
- 24.🌈 Which colour of light is strongest in rgb(239, 42, 19)? (a) green (b) red (c) blue
-
25.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 180px;
padding: 5px;
border: 4px solid black;
margin: 15px;
} -
26.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 450px;
justify-content: space-between;
}
Inside are 4 boxes, each 60px wide (no margins). - 27.💪 Which justify-content value puts boxes in the middle? (a) space-between (b) flex-start (c) flex-end (d) center
-
28.⚖️ What colour is the text of this element?
<p class="star" id="end">Hi</p>
CSS:
#end { color: yellow; }
#end { color: orange; } (a) white (b) orange (c) yellow (d) blue - 29.🎯 What kind of selector is #logo? (a) an id selector (b) an element selector (c) a class selector
- 30.✍️ Which sign goes between a property and its value? (a) - (b) : (c) ; (d) =
- 31.True or false: JavaScript shows a pop-up message. (a) True (b) False
- 32.🎯 Which sign starts an id selector? (a) . (b) & (c) # (d) @
- 33.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
-
34.⚖️ What colour is the text of this element?
<h2 class="red" id="hero">Hi</h2>
CSS:
h2 { color: green; }
h2 { color: white; } (a) white (b) black (c) green (d) purple -
35.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 270px;
padding: 25px;
border: 1px solid black;
margin: 20px;
} -
36.✍️ How many declarations (property: value pairs) are in this rule?
.note {
font-size: 20px;
color: red;
padding: 8px;
} - 37.🖌️ Which CSS property sets the letter colour? (a) background-color (b) font-weight (c) color (d) text-align
-
38.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
font-style: italic;
} - 39.🖌️ Which CSS property picks the font style? (a) color (b) font-family (c) background-color (d) text-align
- 40.🌈 Which hex code is yellow? (a) #ffffff (b) #ff00ff (c) #ffff00 (d) #ff0000
Answer key
- <link>
- an id selector
- colours behind the text
- cyan
- 10
- <style>
- an id selector
- Yes
- white
- makes a link
- an id selector
- packs boxes at the end
- content
- blue
- the screen width
- makes the text bold
- black
- 60
- 64
- Yes
- orange
- True
- red
- red
- 228
- 70
- center
- orange
- an id selector
- :
- True
- #
- an element selector
- white
- 362
- 3
- color
- 1
- font-family
- #ffff00
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids