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: JavaScript changes the text size. (a) False (b) True
- 2.✍️ How does a CSS comment start? (a) /* (b) <!-- (c) // (d) #
-
3.✍️ Which property is set to red in this rule?
p {
color: red;
text-align: center;
font-style: italic;
margin: 10px;
} (a) font-size (b) red (c) text-align (d) color - 4.True or false: CSS reacts to a button click. (a) True (b) False
- 5.📱 min-width: 800px applies when the screen is ___. (a) 800px or wider (b) 800px or narrower (c) exactly 100px (d) turned off
-
6.✍️ What value is given to width in this rule?
.note {
width: 300px;
background-color: yellow;
} (a) 300px (b) italic (c) width (d) red - 7.🔍 Which is the odd one out? (a) sets colours and fonts (b) makes headings and lists (c) makes a link (d) makes a form box
- 8.What does justify-content: center do? (a) equal gaps, none at ends (b) packs boxes at the start (c) puts boxes in the middle (d) packs boxes at the end
- 9.🧩 Which language makes a link? (a) HTML (b) CSS (c) JavaScript
-
10.⚖️ What colour is the text of this element?
<p class="red" id="hero">Hi</p>
CSS:
#hero { color: purple; }
.red { color: red; }
p { color: blue; } (a) yellow (b) red (c) purple (d) blue - 11.🌈 In #00005a the blue part is the hex number 5a. What is it as a normal number?
- 12.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) turned off (c) 600px or narrower (d) 600px or wider
-
13.🖌️ What colour is behind the letters?
h2 {
color: yellow;
background-color: green;
text-align: center;
font-size: 36px;
} (a) green (b) yellow (c) blue -
14.🖌️ What colour is behind the letters?
h1 {
font-size: 28px;
background-color: black;
color: red;
text-align: center;
} (a) red (b) green (c) black -
15.⚖️ What colour is the text of this element?
<h2 class="big" id="end">Hi</h2>
CSS:
#end { color: white; }
#end { color: purple; } (a) purple (b) white (c) black (d) green -
16.⚖️ What colour is the text of this element?
<p class="big" id="intro">Hi</p>
CSS:
.big { color: blue; }
.big { color: green; } (a) blue (b) green (c) purple (d) red -
17.⚖️ What colour is the text of this element?
<h1 class="red" id="intro">Hi</h1>
CSS:
#intro { color: yellow; }
h1 { color: red; } (a) blue (b) white (c) yellow (d) red -
18.🖌️ Where does the text sit on its line?
h1 {
background-color: orange;
font-size: 20px;
text-align: right;
color: red;
} (a) in the middle (b) on the right (c) on the left - 19.💪 Which justify-content value equal gaps, none at ends? (a) flex-end (b) center (c) space-between (d) flex-start
- 20.✍️ In color: blue; which part is the value? (a) color (b) : (c) blue (d) ;
- 21.True or false: #logo is an element selector. (a) False (b) True
-
22.🎯 Which CSS selector matches this element?
<h2 class="box" id="intro">Hello</h2> (a) #main (b) .star (c) .intro (d) h2 -
23.🖌️ What colour are the letters?
h1 {
background-color: green;
font-size: 36px;
color: blue;
text-align: center;
} (a) yellow (b) blue (c) green -
24.✍️ How many declarations (property: value pairs) are in this rule?
body {
color: red;
width: 300px;
font-size: 20px;
text-align: center;
} -
25.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 170px;
justify-content: flex-start;
}
Inside are 3 boxes, each 40px wide (no margins). - 26.Which of these does CSS do? (a) changes the text size (b) puts a picture on a page (c) makes a form box (d) shows a pop-up message
-
27.🖌️ How big is the text, in px?
li {
font-size: 20px;
text-align: center;
color: blue;
background-color: red;
} -
28.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 6px;
}
} (a) Yes (b) No -
29.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 180px;
padding: 15px;
border: 2px solid black;
margin: 20px;
} - 30.🎨 Which tag holds CSS inside the head? (a) <body> (b) <script> (c) <style> (d) <css>
-
31.✍️ What value is given to width in this rule?
#top {
color: red;
text-align: center;
width: 300px;
padding: 8px;
} (a) width (b) red (c) italic (d) 300px -
32.✍️ Which property is set to bold in this rule?
.note {
margin: 10px;
font-size: 20px;
color: red;
font-weight: bold;
} (a) font-weight (b) width (c) border (d) bold - 33.🎯 Which element does the selector #top style? (a) <p id="intro"> (b) <p id="top"> (c) <p class="top"> (d) <h1 class="star">
- 34.What does justify-content: flex-end do? (a) packs boxes at the end (b) packs boxes at the start (c) puts boxes in the middle (d) equal gaps, none at ends
-
35.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 28px;
}
} (a) No (b) Yes -
36.✍️ What value is given to margin in this rule?
#top {
font-style: italic;
width: 300px;
margin: 10px;
font-size: 20px;
} (a) 10px (b) 8px (c) bold (d) margin - 37.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) gap (c) display: flex (d) justify-content
- 38.✍️ In color: blue; which part is the property? (a) : (b) ; (c) blue (d) color
- 39.🎨 One CSS file can style how many pages? (a) only one image (b) no pages (c) many pages (d) only one word
-
40.📦 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: 30px;
border: 3px solid black;
margin: 20px;
}
Answer key
- False
- /*
- color
- False
- 800px or wider
- 300px
- sets colours and fonts
- puts boxes in the middle
- HTML
- purple
- 90
- 600px or narrower
- green
- black
- purple
- green
- yellow
- on the right
- space-between
- blue
- False
- h2
- blue
- 4
- 50
- changes the text size
- 20
- Yes
- 214
- <style>
- 300px
- font-weight
- <p id="top">
- packs boxes at the end
- Yes
- 10px
- display: flex
- color
- many pages
- 216
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids