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.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 14px;
}
} (a) No (b) Yes - 2.🎯 What kind of selector is #hero? (a) an id selector (b) a class selector (c) an element selector
- 3.What does font-weight do? (a) picks the font style (b) makes letters bigger (c) colours behind the text (d) makes the text bold
-
4.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 100px;
padding: 5px;
border: 1px solid black;
margin: 20px;
} - 5.🧩 Which language rounds box corners? (a) JavaScript (b) HTML (c) CSS
- 6.🖌️ Which CSS property makes the text bold? (a) color (b) font-size (c) background-color (d) font-weight
- 7.🌈 Which colour of light is strongest in rgb(0, 61, 178)? (a) green (b) blue (c) red
-
8.🎯 Which CSS selector matches this element?
<h2 class="box" id="hero">Hello</h2> (a) .star (b) li (c) .hero (d) #hero -
9.✍️ What is the selector in this CSS rule?
.note {
background-color: yellow;
width: 300px;
} (a) #top (b) 300px (c) .note (d) background-color - 10.🎯 What kind of selector is .card? (a) an element selector (b) a class selector (c) an id selector
- 11.🌈 Which colour of light is strongest in rgb(35, 178, 135)? (a) red (b) green (c) blue
-
12.🖌️ What colour are the letters?
h1 {
text-align: left;
font-size: 16px;
background-color: blue;
color: white;
} (a) yellow (b) white (c) blue - 13.✍️ Which sign ends each CSS declaration? (a) : (b) ; (c) , (d) .
- 14.📦 In the box model, which part is space outside the border? (a) margin (b) padding (c) border (d) content
- 15.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
- 16.True or false: padding is the text or picture. (a) True (b) False
-
17.✍️ How many declarations (property: value pairs) are in this rule?
.box {
color: red;
font-style: italic;
margin: 10px;
} -
18.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
color: red;
font-size: 20px;
background-color: yellow;
text-align: center;
} - 19.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) 600px or narrower (c) exactly 1000px (d) turned off
- 20.🎯 What kind of selector is #main? (a) a class selector (b) an element selector (c) an id selector
-
21.🎯 Which CSS selector matches this element?
<span class="box" id="logo">Hello</span> (a) p (b) .logo (c) span (d) #end - 22.What does background-color do? (a) picks the font style (b) colours behind the text (c) sets the letter colour (d) makes the text bold
- 23.🌈 Which colour is #ffffff? (a) magenta (b) bright green (c) white (d) red
- 24.📱 What does a media query check? (a) the page title (b) the battery level (c) the time of day (d) the screen width
- 25.True or false: img is a class selector. (a) True (b) False
-
26.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 250px;
padding: 20px;
border: 5px solid black;
margin: 0px;
} - 27.True or false: #top is an element selector. (a) True (b) False
-
28.⚖️ What colour is the text of this element?
<p class="red" id="logo">Hi</p>
CSS:
p { color: green; }
.red { color: red; }
#logo { color: blue; } (a) black (b) red (c) green (d) blue -
29.✍️ Which property is set to 2px solid in this rule?
body {
padding: 8px;
width: 300px;
border: 2px solid;
} (a) border (b) 2px solid (c) width (d) font-style - 30.✍️ In color: blue; which part is the value? (a) blue (b) : (c) ; (d) color
- 31.🎯 What kind of selector is .note? (a) an id selector (b) an element selector (c) a class selector
-
32.⚖️ What colour is the text of this element?
<p class="note" id="logo">Hi</p>
CSS:
.note { color: white; }
#logo { color: blue; } (a) yellow (b) blue (c) white (d) black -
33.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 210px;
padding: 10px;
border: 2px solid black;
margin: 0px;
} - 34.💪 Which justify-content value packs boxes at the start? (a) flex-end (b) center (c) space-between (d) flex-start
- 35.True or false: HTML lays out the page. (a) True (b) False
- 36.What does justify-content: space-between do? (a) packs boxes at the start (b) packs boxes at the end (c) equal gaps, none at ends (d) puts boxes in the middle
- 37.💪 Which justify-content value puts boxes in the middle? (a) flex-start (b) flex-end (c) center (d) space-between
-
38.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 170px;
padding: 15px;
border: 1px solid black;
margin: 5px;
} - 39.📱 Responsive design means a page ___. (a) has no pictures (b) fits every screen (c) is only for laptops (d) never changes
-
40.✍️ Which property is set to 20px in this rule?
.note {
background-color: yellow;
font-size: 20px;
} (a) background-color (b) text-align (c) font-size (d) 20px
Answer key
- Yes
- an id selector
- makes the text bold
- 152
- CSS
- font-weight
- blue
- #hero
- .note
- a class selector
- green
- white
- ;
- margin
- an element selector
- False
- 3
- 4
- 600px or narrower
- an id selector
- span
- colours behind the text
- white
- the screen width
- False
- 300
- False
- blue
- border
- blue
- a class selector
- blue
- 234
- flex-start
- False
- equal gaps, none at ends
- center
- 202
- fits every screen
- font-size
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids