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 value is given to padding in this rule?
h1 {
padding: 8px;
border: 2px solid;
width: 300px;
font-weight: bold;
} (a) bold (b) padding (c) 8px (d) 2px solid -
2.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
background-color: yellow;
font-style: italic;
font-size: 20px;
text-align: center;
} - 3.Which of these does HTML do? (a) lays out the page (b) checks a quiz answer (c) puts a picture on a page (d) reacts to a button click
-
4.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 22px;
}
} - 5.🌈 In #00f400 the green part is the hex number f4. What is it as a normal number?
-
6.🖌️ What colour is behind the letters?
h1 {
font-size: 28px;
text-align: center;
background-color: yellow;
color: blue;
} (a) yellow (b) green (c) blue - 7.🌈 Which colour is rgb(255, 0, 255)? (a) magenta (b) black (c) cyan (d) bright green
- 8.💪 Which justify-content value packs boxes at the end? (a) flex-end (b) flex-start (c) center (d) space-between
- 9.🌈 In #800000 the red part is the hex number 80. What is it as a normal number?
-
10.🖌️ How big is the text, in px?
p {
background-color: green;
font-size: 20px;
text-align: center;
color: blue;
} - 11.What does justify-content: flex-start do? (a) equal gaps, none at ends (b) packs boxes at the start (c) puts boxes in the middle (d) packs boxes at the end
- 12.True or false: HTML makes headings and lists. (a) True (b) False
- 13.📦 In the box model, which part is the line round the box? (a) content (b) padding (c) margin (d) border
-
14.⚖️ What colour is the text of this element?
<p class="note" id="intro">Hi</p>
CSS:
.note { color: red; }
.note { color: green; } (a) red (b) purple (c) green (d) blue -
15.🎯 Which CSS selector matches this element?
<h1 class="star" id="hero">Hello</h1> (a) h2 (b) .menu (c) #star (d) #hero - 16.💪 Which flexbox property turns on flexbox? (a) justify-content (b) gap (c) display: flex (d) align-items
- 17.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
- 18.🖌️ Which CSS property sets the letter colour? (a) color (b) font-family (c) text-align (d) font-weight
-
19.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 22px;
}
} (a) No (b) Yes - 20.✍️ CSS declarations go inside which brackets? (a) < > (b) { } (c) [ ] (d) ( )
-
21.🖌️ Where does the text sit on its line?
h2 {
background-color: black;
text-align: right;
font-size: 24px;
color: yellow;
} (a) on the right (b) on the left (c) in the middle - 22.🌈 Which hex code is black? (a) #00ffff (b) #ff00ff (c) #000000 (d) #0000ff
-
23.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 180px;
justify-content: flex-end;
}
Inside are 4 boxes, each 40px wide (no margins). - 24.💪 Which flexbox property picks row or column? (a) align-items (b) display: flex (c) gap (d) flex-direction
-
25.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 1024px) {
p {
font-size: 28px;
}
} (a) No (b) Yes -
26.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 1024px) {
p {
font-size: 18px;
}
} (a) No (b) Yes - 27.True or false: JavaScript puts a picture on a page. (a) False (b) True
-
28.⚖️ What colour is the text of this element?
<p class="star" id="intro">Hi</p>
CSS:
.star { color: black; }
#intro { color: green; }
p { color: yellow; } (a) green (b) yellow (c) black (d) orange - 29.💪 Which justify-content value packs boxes at the start? (a) center (b) space-between (c) flex-start (d) flex-end
- 30.🎯 Can many elements share the same class? (a) No (b) Yes
- 31.🖌️ Which CSS property colours behind the text? (a) background-color (b) color (c) font-weight (d) font-family
-
32.⚖️ What colour is the text of this element?
<h2 class="box" id="main">Hi</h2>
CSS:
.box { color: green; }
.box { color: yellow; } (a) yellow (b) red (c) white (d) green -
33.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 190px;
padding: 20px;
border: 4px solid black;
margin: 0px;
} - 34.🎯 What kind of selector is li? (a) a class selector (b) an element selector (c) an id selector
- 35.🌈 In #000072 the blue part is the hex number 72. What is it as a normal number?
- 36.📦 In the box model, which part is space outside the border? (a) border (b) padding (c) content (d) margin
- 37.True or false: img is an id selector. (a) True (b) False
- 38.True or false: CSS sets colours and fonts. (a) True (b) False
-
39.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 20px;
}
} -
40.✍️ How many declarations (property: value pairs) are in this rule?
body {
text-align: center;
border: 2px solid;
font-style: italic;
}
Answer key
- 8px
- 4
- puts a picture on a page
- 22
- 244
- yellow
- magenta
- flex-end
- 128
- 20
- packs boxes at the start
- True
- border
- green
- #hero
- display: flex
- an element selector
- color
- Yes
- { }
- on the right
- #000000
- 20
- flex-direction
- No
- No
- False
- green
- flex-start
- Yes
- background-color
- yellow
- 238
- an element selector
- 114
- margin
- False
- True
- 20
- 3
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids