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 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 14px;
}
} - 2.🌈 Which colour is #000000? (a) blue (b) black (c) white (d) cyan
-
3.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 20px;
}
} -
4.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 220px;
padding: 5px;
border: 2px solid black;
margin: 15px;
} - 5.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) neither (c) the later one (d) the first one
- 6.🎯 What kind of selector is h1? (a) a class selector (b) an element selector (c) an id selector
- 7.🌈 In #rrggbb, which colour do the last two digits give? (a) white (b) green (c) red (d) blue
-
8.✍️ How many declarations (property: value pairs) are in this rule?
#top {
color: red;
text-align: center;
margin: 10px;
width: 300px;
} - 9.🔍 Which is the odd one out? (a) makes a link (b) counts down a timer (c) gives the page structure (d) puts a picture on a page
- 10.True or false: .big is a class selector. (a) True (b) False
- 11.📱 Responsive design means a page ___. (a) never changes (b) fits every screen (c) is only for laptops (d) has no pictures
- 12.True or false: #hero is an id selector. (a) False (b) True
- 13.📦 In the box model, which part is the line round the box? (a) margin (b) content (c) border (d) padding
- 14.What does justify-content: flex-end do? (a) puts boxes in the middle (b) equal gaps, none at ends (c) packs boxes at the start (d) packs boxes at the end
- 15.🎨 Which tag holds CSS inside the head? (a) <style> (b) <body> (c) <css> (d) <script>
-
16.✍️ What is the selector in this CSS rule?
.box {
color: red;
background-color: yellow;
} (a) color (b) yellow (c) h2 (d) .box -
17.⚖️ What colour is the text of this element?
<p class="red" id="logo">Hi</p>
CSS:
p { color: orange; }
.red { color: red; } (a) orange (b) white (c) yellow (d) red - 18.True or false: the border is space inside the border. (a) True (b) False
- 19.🎨 Which tag connects an outside CSS file? (a) <css> (b) <link> (c) <img> (d) <a>
-
20.🖌️ Where does the text sit on its line?
h2 {
text-align: right;
color: white;
background-color: red;
font-size: 20px;
} (a) on the right (b) on the left (c) in the middle - 21.True or false: HTML rounds box corners. (a) False (b) True
-
22.✍️ What value is given to font-size in this rule?
.note {
font-size: 20px;
text-align: center;
} (a) font-size (b) center (c) 20px (d) yellow - 23.🖌️ Which CSS property colours behind the text? (a) color (b) font-size (c) background-color (d) font-family
-
24.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 6px;
}
} (a) Yes (b) No -
25.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 110px;
padding: 25px;
border: 4px solid black;
margin: 0px;
} - 26.🖌️ Which CSS property makes letters bigger? (a) color (b) font-size (c) font-family (d) text-align
-
27.✍️ What value is given to margin in this rule?
h1 {
margin: 10px;
color: red;
} (a) 10px (b) margin (c) 8px (d) bold - 28.Which of these does CSS do? (a) makes a link (b) makes headings and lists (c) gives the page structure (d) changes the text size
-
29.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 32px;
}
} (a) No (b) Yes - 30.💪 Which flexbox property spaces boxes along a row? (a) justify-content (b) display: flex (c) flex-direction (d) gap
- 31.Which of these is margin? (a) the text or picture (b) the gap round content (c) space outside the border (d) a solid or dotted edge
- 32.What does text-align do? (a) colours behind the text (b) centres a heading (c) picks the font style (d) makes the text bold
-
33.⚖️ What colour is the text of this element?
<p class="star" id="logo">Hi</p>
CSS:
p { color: green; }
#logo { color: orange; } (a) red (b) green (c) orange (d) blue -
34.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 28px;
}
} (a) No (b) Yes - 35.True or false: p is a class selector. (a) True (b) False
- 36.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the title tag (c) the br tag (d) the viewport meta tag
- 37.🌈 In #000031 the blue part is the hex number 31. What is it as a normal number?
- 38.💪 Which flexbox property lines boxes up across? (a) justify-content (b) display: flex (c) align-items (d) flex-direction
- 39.🎯 What kind of selector is .big? (a) an id selector (b) an element selector (c) a class selector
-
40.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 140px;
justify-content: space-between;
}
Inside are 2 boxes, each 40px wide (no margins).
Answer key
- 16
- black
- 20
- 264
- the later one
- an element selector
- blue
- 4
- counts down a timer
- True
- fits every screen
- True
- border
- packs boxes at the end
- <style>
- .box
- red
- False
- <link>
- on the right
- False
- 20px
- background-color
- Yes
- 168
- font-size
- 10px
- changes the text size
- Yes
- justify-content
- space outside the border
- centres a heading
- orange
- No
- False
- the viewport meta tag
- 49
- align-items
- a class selector
- 60
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids