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 of these does JavaScript do? (a) changes the page live (b) makes a form box (c) changes the text size (d) puts a picture on a page
-
2.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} -
3.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} (a) No (b) Yes -
4.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 360px;
justify-content: flex-start;
}
Inside are 3 boxes, each 100px wide (no margins). -
5.🖌️ What colour are the letters?
li {
text-align: left;
background-color: yellow;
color: white;
font-size: 32px;
} (a) yellow (b) white (c) blue -
6.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 50px;
padding: 30px;
border: 4px solid black;
margin: 0px;
} - 7.📱 Which tag helps phones show a page at the right size? (a) the br tag (b) the title tag (c) the hr tag (d) the viewport meta tag
- 8.📦 In the box model, which part is a solid or dotted edge? (a) margin (b) content (c) padding (d) border
- 9.🔍 Which is the odd one out? (a) sets colours and fonts (b) lays out the page (c) puts a picture on a page (d) changes the text size
- 10.💪 Which justify-content value packs boxes at the end? (a) flex-start (b) center (c) space-between (d) flex-end
- 11.True or false: CSS adds space around boxes. (a) False (b) True
-
12.⚖️ What colour is the text of this element?
<h2 class="menu" id="intro">Hi</h2>
CSS:
.menu { color: blue; }
.menu { color: white; } (a) black (b) yellow (c) blue (d) white -
13.✍️ Which property is set to center in this rule?
h2 {
text-align: center;
font-weight: bold;
} (a) background-color (b) margin (c) text-align (d) center - 14.True or false: .big is a class selector. (a) True (b) False
- 15.🌈 In #rrggbb, which colour do the last two digits give? (a) white (b) blue (c) green (d) red
-
16.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 250px;
padding: 5px;
border: 5px solid black;
margin: 10px;
} -
17.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 210px;
justify-content: flex-start;
}
Inside are 3 boxes, each 50px wide (no margins). - 18.What does justify-content: center do? (a) puts boxes in the middle (b) packs boxes at the start (c) equal gaps, none at ends (d) packs boxes at the end
-
19.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} - 20.What does font-family do? (a) makes letters bigger (b) sets the letter colour (c) picks the font style (d) centres a heading
- 21.What does text-align do? (a) sets the letter colour (b) centres a heading (c) makes letters bigger (d) colours behind the text
-
22.✍️ Which property is set to 20px in this rule?
h1 {
font-size: 20px;
margin: 10px;
width: 300px;
padding: 8px;
} (a) 20px (b) text-align (c) background-color (d) font-size - 23.✍️ In color: blue; which part is the property? (a) blue (b) : (c) ; (d) color
- 24.Which of these is padding? (a) the line round the box (b) the gap to other boxes (c) space outside the border (d) the gap round content
-
25.✍️ What value is given to width in this rule?
p {
color: red;
width: 300px;
} (a) width (b) red (c) 300px (d) italic -
26.🖌️ What colour are the letters?
li {
font-size: 32px;
color: orange;
background-color: blue;
text-align: center;
} (a) yellow (b) blue (c) orange -
27.🖌️ Where does the text sit on its line?
p {
text-align: center;
font-size: 20px;
color: green;
background-color: orange;
} (a) in the middle (b) on the left (c) on the right - 28.🌈 Which colour is rgb(0, 0, 255)? (a) yellow (b) bright green (c) magenta (d) blue
-
29.⚖️ What colour is the text of this element?
<p class="big" id="main">Hi</p>
CSS:
p { color: red; }
p { color: green; } (a) blue (b) red (c) black (d) green - 30.🌈 Which colour of light is strongest in rgb(169, 127, 62)? (a) red (b) green (c) blue
- 31.What does justify-content: space-between do? (a) packs boxes at the start (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the end
-
32.🎯 Which CSS selector matches this element?
<h2 class="menu" id="logo">Hello</h2> (a) .note (b) .logo (c) #menu (d) h2 - 33.🧩 Which language shows a pop-up message? (a) CSS (b) JavaScript (c) HTML
- 34.✍️ Which sign ends each CSS declaration? (a) , (b) . (c) ; (d) :
- 35.🎯 Which sign starts a class selector? (a) . (b) # (c) & (d) @
-
36.🖌️ What colour are the letters?
h1 {
background-color: purple;
text-align: left;
font-size: 28px;
color: yellow;
} (a) white (b) yellow (c) purple - 37.🌈 What is the biggest number one colour can have in rgb()? (a) 100 (b) 255 (c) 1000 (d) 99
-
38.✍️ How many declarations (property: value pairs) are in this rule?
.note {
border: 2px solid;
text-align: center;
padding: 8px;
} -
39.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 14px;
}
} (a) No (b) Yes - 40.🎯 What kind of selector is #main? (a) a class selector (b) an element selector (c) an id selector
Answer key
- changes the page live
- 24
- No
- 60
- white
- 118
- the viewport meta tag
- border
- puts a picture on a page
- flex-end
- True
- white
- text-align
- True
- blue
- 290
- 60
- puts boxes in the middle
- 18
- picks the font style
- centres a heading
- font-size
- color
- the gap round content
- 300px
- orange
- in the middle
- blue
- green
- red
- equal gaps, none at ends
- h2
- JavaScript
- ;
- .
- yellow
- 255
- 3
- No
- an id selector
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids