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.True or false: HTML makes a form box. (a) True (b) False
- 2.🎯 How many elements on a page should have the same id? (a) 1 (b) 2 (c) 5 (d) any number
-
3.✍️ Which property is set to yellow in this rule?
body {
width: 300px;
background-color: yellow;
} (a) margin (b) yellow (c) padding (d) background-color - 4.🌈 Which colour is rgb(255, 0, 255)? (a) bright green (b) red (c) magenta (d) white
-
5.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 80px;
padding: 5px;
border: 1px solid black;
margin: 20px;
} - 6.💪 Which justify-content value equal gaps, none at ends? (a) space-between (b) flex-start (c) flex-end (d) center
-
7.🖌️ What colour are the letters?
li {
background-color: yellow;
font-size: 12px;
text-align: center;
color: blue;
} (a) blue (b) purple (c) yellow -
8.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 190px;
justify-content: space-between;
}
Inside are 2 boxes, each 80px wide (no margins). - 9.🎯 Which element does the selector li style? (a) <li class="box"> (b) <div> (c) <p id="end"> (d) <span class="box">
- 10.🌈 Which colour of light is strongest in rgb(47, 101, 153)? (a) green (b) red (c) blue
- 11.True or false: HTML counts down a timer. (a) True (b) False
-
12.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 14px;
}
} -
13.⚖️ What colour is the text of this element?
<h1 class="note" id="end">Hi</h1>
CSS:
h1 { color: purple; }
#end { color: black; } (a) purple (b) orange (c) red (d) black -
14.✍️ Which property is set to center in this rule?
p {
font-size: 20px;
text-align: center;
} (a) text-align (b) center (c) background-color (d) margin - 15.🌈 In #rrggbb, which colour do the first two digits give? (a) blue (b) red (c) black (d) green
- 16.🎯 What kind of selector is p? (a) an element selector (b) an id selector (c) a class selector
-
17.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
color: red;
font-weight: bold;
font-style: italic;
} - 18.💪 Which justify-content value packs boxes at the start? (a) space-between (b) flex-start (c) center (d) flex-end
-
19.⚖️ What colour is the text of this element?
<p class="big" id="hero">Hi</p>
CSS:
.big { color: blue; }
.big { color: yellow; } (a) orange (b) yellow (c) purple (d) blue -
20.🎯 Which CSS selector matches this element?
<li class="big" id="top">Hello</li> (a) #intro (b) .big (c) div (d) .red - 21.🎯 Can many elements share the same class? (a) No (b) Yes
-
22.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} (a) Yes (b) No - 23.🎯 Which element does the selector #logo style? (a) <h2 id="end"> (b) <li class="menu"> (c) <h2 class="logo"> (d) <h2 id="logo">
-
24.🖌️ What colour are the letters?
h1 {
font-size: 28px;
background-color: black;
text-align: right;
color: purple;
} (a) orange (b) purple (c) black - 25.🎯 What kind of selector is .note? (a) a class selector (b) an element selector (c) an id selector
-
26.🖌️ How big is the text, in px?
p {
background-color: yellow;
color: orange;
font-size: 32px;
text-align: right;
} - 27.🌈 In #720000 the red part is the hex number 72. What is it as a normal number?
- 28.✍️ How does a CSS comment start? (a) // (b) /* (c) # (d) <!--
-
29.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
border: 2px solid;
} -
30.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 170px;
justify-content: flex-start;
}
Inside are 2 boxes, each 50px wide (no margins). - 31.🎨 Which tag holds CSS inside the head? (a) <style> (b) <script> (c) <css> (d) <body>
-
32.⚖️ What colour is the text of this element?
<h1 class="box" id="intro">Hi</h1>
CSS:
h1 { color: blue; }
h1 { color: purple; } (a) purple (b) red (c) blue (d) yellow -
33.✍️ Which property is set to 300px in this rule?
.box {
width: 300px;
text-align: center;
font-size: 20px;
background-color: yellow;
} (a) 300px (b) width (c) font-style (d) color - 34.🧩 Which language gives the page structure? (a) HTML (b) JavaScript (c) CSS
- 35.✍️ Which sign goes between a property and its value? (a) : (b) = (c) ; (d) -
- 36.🌈 Hex digits go 0 to 9, then A to which letter? (a) Z (b) J (c) G (d) F
- 37.💪 Which justify-content value packs boxes at the end? (a) space-between (b) flex-start (c) flex-end (d) center
-
38.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 10px;
}
} (a) Yes (b) No - 39.True or false: .big is an id selector. (a) True (b) False
- 40.True or false: JavaScript sets colours and fonts. (a) False (b) True
Answer key
- True
- 1
- background-color
- magenta
- 132
- space-between
- blue
- 30
- <li class="box">
- blue
- False
- 20
- black
- text-align
- red
- an element selector
- 3
- flex-start
- yellow
- .big
- Yes
- Yes
- <h2 id="logo">
- purple
- a class selector
- 32
- 114
- /*
- 1
- 70
- <style>
- purple
- width
- HTML
- :
- F
- flex-end
- Yes
- False
- False
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids