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 selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
- 2.🖌️ Which CSS property sets the letter colour? (a) background-color (b) font-family (c) font-size (d) color
- 3.🌈 In #00d800 the green part is the hex number d8. What is it as a normal number?
-
4.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 28px;
}
} - 5.Which of these is padding? (a) the line round the box (b) space inside the border (c) space outside the border (d) the text or picture
- 6.🌈 In #rrggbb, which colour do the first two digits give? (a) red (b) black (c) blue (d) green
- 7.🎯 How many elements on a page should have the same id? (a) 1 (b) 2 (c) 5 (d) any number
-
8.⚖️ What colour is the text of this element?
<h2 class="menu" id="top">Hi</h2>
CSS:
#top { color: blue; }
.menu { color: yellow; } (a) blue (b) white (c) purple (d) yellow - 9.🎯 Which element does the selector #end style? (a) <div id="end"> (b) <div id="hero"> (c) <span class="note"> (d) <div class="end">
-
10.🖌️ How big is the text, in px?
h1 {
font-size: 16px;
color: orange;
text-align: center;
background-color: purple;
} - 11.🎨 Which tag connects an outside CSS file? (a) <a> (b) <css> (c) <link> (d) <img>
- 12.🌈 What is the biggest number one colour can have in rgb()? (a) 1000 (b) 100 (c) 99 (d) 255
- 13.🎯 Which element does the selector #intro style? (a) <span class="intro"> (b) <span id="main"> (c) <p class="note"> (d) <span id="intro">
-
14.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 310px;
justify-content: flex-end;
}
Inside are 4 boxes, each 60px wide (no margins). - 15.🔍 Which is the odd one out? (a) makes a link (b) puts a picture on a page (c) makes headings and lists (d) changes the text size
-
16.🖌️ What colour are the letters?
li {
background-color: blue;
font-size: 16px;
text-align: center;
color: white;
} (a) white (b) green (c) blue - 17.What does justify-content: space-between do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the start (d) packs boxes at the end
- 18.⚖️ Which selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
- 19.🧩 Which language changes the page live? (a) CSS (b) JavaScript (c) HTML
- 20.🌈 In #c40000 the red part is the hex number c4. What is it as a normal number?
- 21.🎯 What kind of selector is li? (a) an id selector (b) a class selector (c) an element selector
- 22.🖌️ Which CSS property makes the text bold? (a) font-size (b) color (c) text-align (d) font-weight
- 23.True or false: .big is an id selector. (a) False (b) True
- 24.What does color do? (a) picks the font style (b) centres a heading (c) colours behind the text (d) sets the letter colour
- 25.True or false: CSS makes headings and lists. (a) False (b) True
- 26.🎯 Which sign starts an id selector? (a) . (b) @ (c) & (d) #
- 27.🌈 Which colour is #0000ff? (a) cyan (b) blue (c) white (d) magenta
-
28.✍️ What value is given to margin in this rule?
h2 {
margin: 10px;
background-color: yellow;
font-style: italic;
} (a) bold (b) margin (c) 8px (d) 10px -
29.⚖️ What colour is the text of this element?
<h1 class="star" id="top">Hi</h1>
CSS:
h1 { color: black; }
h1 { color: red; } (a) red (b) yellow (c) black (d) blue -
30.⚖️ What colour is the text of this element?
<h2 class="red" id="hero">Hi</h2>
CSS:
.red { color: orange; }
.red { color: green; } (a) orange (b) red (c) purple (d) green - 31.True or false: JavaScript shows a pop-up message. (a) True (b) False
- 32.What does font-family do? (a) makes letters bigger (b) picks the font style (c) sets the letter colour (d) makes the text bold
-
33.🖌️ How big is the text, in px?
h2 {
text-align: left;
background-color: black;
font-size: 16px;
color: white;
} -
34.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 120px;
padding: 30px;
border: 2px solid black;
margin: 15px;
} -
35.🎯 Which CSS selector matches this element?
<li class="big" id="logo">Hello</li> (a) #end (b) .red (c) li (d) #big -
36.✍️ What is the selector in this CSS rule?
.note {
border: 2px solid;
padding: 8px;
font-weight: bold;
} (a) border (b) #top (c) 8px (d) .note -
37.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 90px;
padding: 5px;
border: 2px solid black;
margin: 10px;
} -
38.✍️ What is the selector in this CSS rule?
h2 {
font-style: italic;
padding: 8px;
font-weight: bold;
margin: 10px;
} (a) h2 (b) font-style (c) 8px (d) h1 - 39.💪 Which flexbox property spaces boxes along a row? (a) flex-direction (b) justify-content (c) display: flex (d) align-items
- 40.🌈 Which colour is #ff0000? (a) blue (b) bright green (c) red (d) magenta
Answer key
- an element selector
- color
- 216
- 24
- space inside the border
- red
- 1
- blue
- <div id="end">
- 16
- <link>
- 255
- <span id="intro">
- 70
- changes the text size
- white
- equal gaps, none at ends
- an id selector
- JavaScript
- 196
- an element selector
- font-weight
- False
- sets the letter colour
- False
- #
- blue
- 10px
- red
- green
- True
- picks the font style
- 16
- 214
- li
- .note
- 124
- h2
- justify-content
- red
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids