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.What does justify-content: center do? (a) packs boxes at the start (b) equal gaps, none at ends (c) packs boxes at the end (d) puts boxes in the middle
-
2.⚖️ What colour is the text of this element?
<p class="box" id="intro">Hi</p>
CSS:
#intro { color: red; }
.box { color: green; }
p { color: orange; } (a) red (b) green (c) black (d) orange -
3.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} -
4.🖌️ How big is the text, in px?
h2 {
background-color: blue;
text-align: center;
color: yellow;
font-size: 24px;
} -
5.🖌️ What colour is behind the letters?
h1 {
font-size: 32px;
background-color: white;
text-align: center;
color: red;
} (a) red (b) white (c) yellow - 6.🌈 Which hex code is black? (a) #000000 (b) #ff0000 (c) #ffffff (d) #ffff00
-
7.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 18px;
}
} (a) No (b) Yes - 8.💪 Which flexbox property spaces boxes along a row? (a) flex-direction (b) display: flex (c) justify-content (d) align-items
-
9.✍️ Which property is set to yellow in this rule?
p {
border: 2px solid;
background-color: yellow;
} (a) margin (b) yellow (c) padding (d) background-color - 10.🖌️ Which CSS property makes the text bold? (a) font-size (b) font-weight (c) background-color (d) text-align
- 11.📦 In the box model, which part is the gap round content? (a) content (b) padding (c) border (d) margin
-
12.🎯 Which CSS selector matches this element?
<p class="note" id="top">Hello</p> (a) .note (b) #note (c) .big (d) #intro - 13.🌈 Which colour is rgb(255, 0, 255)? (a) blue (b) black (c) magenta (d) bright green
-
14.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 20px;
}
} (a) Yes (b) No - 15.What does justify-content: flex-start do? (a) puts boxes in the middle (b) packs boxes at the start (c) packs boxes at the end (d) equal gaps, none at ends
- 16.True or false: CSS puts a picture on a page. (a) True (b) False
-
17.✍️ What is the selector in this CSS rule?
p {
width: 300px;
font-style: italic;
color: red;
padding: 8px;
} (a) width (b) .note (c) italic (d) p -
18.✍️ How many declarations (property: value pairs) are in this rule?
.box {
padding: 8px;
font-weight: bold;
text-align: center;
width: 300px;
} -
19.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 70px;
padding: 30px;
border: 4px solid black;
margin: 0px;
} -
20.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 220px;
justify-content: flex-end;
}
Inside are 2 boxes, each 80px wide (no margins). -
21.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 16px;
}
} - 22.💪 Which justify-content value packs boxes at the start? (a) space-between (b) flex-end (c) center (d) flex-start
- 23.🎯 Which sign starts an id selector? (a) # (b) . (c) @ (d) &
-
24.🖌️ What colour are the letters?
h1 {
text-align: center;
font-size: 28px;
color: white;
background-color: green;
} (a) white (b) black (c) green - 25.🌈 Which colour is #ff0000? (a) white (b) red (c) black (d) blue
- 26.True or false: padding is space inside the border. (a) False (b) True
-
27.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 300px;
padding: 30px;
border: 5px solid black;
margin: 20px;
} - 28.🎨 Which attribute adds CSS inside one tag? (a) src (b) style (c) href (d) alt
-
29.✍️ What value is given to font-weight in this rule?
li {
padding: 8px;
background-color: yellow;
color: red;
font-weight: bold;
} (a) font-weight (b) 2px solid (c) 300px (d) bold - 30.True or false: li is an id selector. (a) True (b) False
- 31.Which of these does HTML do? (a) changes the page live (b) gives the page structure (c) checks a quiz answer (d) reacts to a button click
- 32.True or false: body is an element selector. (a) True (b) False
- 33.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the viewport meta tag (c) the title tag (d) the br tag
- 34.True or false: .big is an element selector. (a) False (b) True
- 35.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) justify-content (c) gap (d) display: flex
-
36.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 460px;
justify-content: center;
}
Inside are 3 boxes, each 100px wide (no margins). - 37.What does background-color do? (a) picks the font style (b) sets the letter colour (c) makes the text bold (d) colours behind the text
- 38.🌈 What is the biggest number one colour can have in rgb()? (a) 100 (b) 1000 (c) 99 (d) 255
- 39.📦 In the box model, which part is the gap to other boxes? (a) padding (b) border (c) margin (d) content
- 40.✍️ In color: blue; which part is the property? (a) blue (b) : (c) ; (d) color
Answer key
- puts boxes in the middle
- red
- 20
- 24
- white
- #000000
- Yes
- justify-content
- background-color
- font-weight
- padding
- .note
- magenta
- No
- packs boxes at the start
- False
- p
- 4
- 138
- 60
- 16
- flex-start
- #
- white
- red
- True
- 410
- style
- bold
- False
- gives the page structure
- True
- the viewport meta tag
- False
- display: flex
- 80
- colours behind the text
- 255
- margin
- color
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids