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 property is set to 10px in this rule?
.box {
margin: 10px;
width: 300px;
} (a) 10px (b) font-weight (c) padding (d) margin - 2.Which of these is the content? (a) space inside the border (b) the text or picture (c) a solid or dotted edge (d) the gap to other boxes
- 3.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the first one (c) the shorter one (d) neither
-
4.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 90px;
padding: 20px;
border: 4px solid black;
margin: 5px;
} -
5.🖌️ What colour is behind the letters?
h1 {
color: white;
background-color: purple;
text-align: left;
font-size: 24px;
} (a) purple (b) white (c) green - 6.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or wider (c) turned off (d) 600px or narrower
-
7.✍️ Which property is set to 20px in this rule?
h2 {
font-size: 20px;
font-style: italic;
} (a) background-color (b) 20px (c) text-align (d) font-size - 8.🌈 What is the biggest number one colour can have in rgb()? (a) 99 (b) 100 (c) 1000 (d) 255
- 9.📱 What does a media query check? (a) the time of day (b) the page title (c) the screen width (d) the battery level
-
10.🎯 Which CSS selector matches this element?
<h2 class="note" id="intro">Hello</h2> (a) #note (b) #intro (c) .intro (d) .big - 11.🌈 Which colour is #ffff00? (a) bright green (b) red (c) black (d) yellow
- 12.🎯 How many elements on a page should have the same id? (a) 2 (b) 5 (c) any number (d) 1
-
13.✍️ Which property is set to red in this rule?
body {
margin: 10px;
background-color: yellow;
font-weight: bold;
color: red;
} (a) font-size (b) red (c) text-align (d) color - 14.🎯 Which sign starts an id selector? (a) @ (b) & (c) . (d) #
- 15.True or false: CSS lays out the page. (a) False (b) True
-
16.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 110px;
padding: 20px;
border: 5px solid black;
margin: 5px;
} -
17.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 250px;
padding: 10px;
border: 1px solid black;
margin: 5px;
} - 18.🎯 What kind of selector is #end? (a) an id selector (b) a class selector (c) an element selector
-
19.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 24px;
}
} - 20.🧩 Which language makes a link? (a) CSS (b) JavaScript (c) HTML
-
21.🎯 Which CSS selector matches this element?
<h1 class="star" id="end">Hello</h1> (a) .menu (b) h1 (c) #star (d) .end -
22.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 90px;
padding: 10px;
border: 2px solid black;
margin: 0px;
} -
23.✍️ What value is given to border in this rule?
#top {
font-weight: bold;
background-color: yellow;
border: 2px solid;
margin: 10px;
} (a) border (b) 2px solid (c) 300px (d) italic -
24.🎯 Which CSS selector matches this element?
<span class="note" id="top">Hello</span> (a) p (b) #intro (c) .note (d) .big -
25.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 200px;
padding: 5px;
border: 1px solid black;
margin: 20px;
} - 26.🎯 What kind of selector is .card? (a) an element selector (b) an id selector (c) a class selector
-
27.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 340px;
justify-content: flex-end;
}
Inside are 4 boxes, each 80px wide (no margins). -
28.✍️ Which property is set to yellow in this rule?
h2 {
color: red;
background-color: yellow;
} (a) margin (b) background-color (c) yellow (d) padding -
29.🖌️ Where does the text sit on its line?
p {
background-color: white;
color: purple;
text-align: left;
font-size: 32px;
} (a) on the right (b) on the left (c) in the middle -
30.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 2 boxes, each 100px wide (no margins). -
31.🖌️ How big is the text, in px?
p {
font-size: 28px;
color: white;
text-align: right;
background-color: purple;
} - 32.True or false: the border is space outside the border. (a) False (b) True
- 33.🧩 Which language adds space around boxes? (a) JavaScript (b) HTML (c) CSS
- 34.📦 In the box model, which part is space inside the border? (a) margin (b) padding (c) border (d) content
-
35.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 210px;
justify-content: space-between;
}
Inside are 2 boxes, each 80px wide (no margins). -
36.⚖️ What colour is the text of this element?
<h1 class="note" id="hero">Hi</h1>
CSS:
.note { color: yellow; }
.note { color: green; } (a) yellow (b) green (c) blue (d) black -
37.🖌️ What colour are the letters?
h1 {
text-align: right;
background-color: black;
font-size: 16px;
color: red;
} (a) black (b) green (c) red - 38.True or false: HTML puts a picture on a page. (a) False (b) True
-
39.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 130px;
justify-content: flex-start;
}
Inside are 2 boxes, each 40px wide (no margins). - 40.True or false: the border is the line round the box. (a) True (b) False
Answer key
- margin
- the text or picture
- the later one
- 138
- purple
- 600px or narrower
- font-size
- 255
- the screen width
- #intro
- yellow
- 1
- color
- #
- True
- 170
- 272
- an id selector
- 20
- HTML
- h1
- 114
- 2px solid
- .note
- 252
- a class selector
- 20
- background-color
- on the left
- 30
- 28
- False
- CSS
- padding
- 50
- green
- red
- True
- 50
- True
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids