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.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the first one (c) the later one (d) the shorter one
- 2.🌈 Which colour is #ff0000? (a) cyan (b) red (c) black (d) magenta
-
3.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 230px;
justify-content: space-between;
}
Inside are 2 boxes, each 80px wide (no margins). -
4.⚖️ What colour is the text of this element?
<h2 class="big" id="end">Hi</h2>
CSS:
#end { color: green; }
.big { color: blue; } (a) purple (b) black (c) green (d) blue - 5.💪 Which flexbox property spaces boxes along a row? (a) gap (b) justify-content (c) align-items (d) display: flex
- 6.True or false: padding is the gap to other boxes. (a) True (b) False
- 7.🌈 Hex digits go 0 to 9, then A to which letter? (a) J (b) G (c) Z (d) F
-
8.💪 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 60px wide (no margins). - 9.📦 In the box model, which part is the text or picture? (a) border (b) padding (c) content (d) margin
- 10.🎨 Which tag holds CSS inside the head? (a) <body> (b) <style> (c) <css> (d) <script>
- 11.🌈 In #000010 the blue part is the hex number 10. What is it as a normal number?
-
12.🖌️ Where does the text sit on its line?
li {
background-color: black;
color: red;
font-size: 28px;
text-align: right;
} (a) in the middle (b) on the left (c) on the right -
13.⚖️ What colour is the text of this element?
<p class="star" id="main">Hi</p>
CSS:
#main { color: blue; }
.star { color: yellow; }
p { color: black; } (a) yellow (b) blue (c) green (d) black - 14.✍️ In color: blue; which part is the value? (a) color (b) ; (c) : (d) blue
-
15.⚖️ What colour is the text of this element?
<h2 class="menu" id="intro">Hi</h2>
CSS:
#intro { color: green; }
#intro { color: yellow; } (a) black (b) green (c) yellow (d) orange - 16.🌈 Which colour is rgb(0, 0, 255)? (a) blue (b) white (c) red (d) yellow
- 17.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
- 18.💪 Which justify-content value packs boxes at the start? (a) space-between (b) center (c) flex-end (d) flex-start
- 19.🖌️ Which CSS property makes letters bigger? (a) font-size (b) background-color (c) font-family (d) text-align
- 20.✍️ How does a CSS comment start? (a) /* (b) <!-- (c) # (d) //
-
21.🖌️ How big is the text, in px?
li {
color: purple;
text-align: right;
background-color: white;
font-size: 20px;
} -
22.✍️ What value is given to font-weight in this rule?
.box {
font-weight: bold;
border: 2px solid;
padding: 8px;
background-color: yellow;
} (a) font-weight (b) 2px solid (c) 300px (d) bold -
23.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 260px;
justify-content: flex-start;
}
Inside are 4 boxes, each 60px wide (no margins). - 24.True or false: JavaScript shows a pop-up message. (a) True (b) False
- 25.What does justify-content: flex-end do? (a) packs boxes at the start (b) puts boxes in the middle (c) packs boxes at the end (d) equal gaps, none at ends
-
26.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 24px;
}
} -
27.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 120px;
padding: 15px;
border: 2px solid black;
margin: 5px;
} - 28.Which of these is the content? (a) a solid or dotted edge (b) the gap round content (c) space outside the border (d) the text or picture
-
29.✍️ How many declarations (property: value pairs) are in this rule?
p {
color: red;
background-color: yellow;
border: 2px solid;
} - 30.🌈 In #00f400 the green part is the hex number f4. What is it as a normal number?
-
31.🖌️ Where does the text sit on its line?
h1 {
background-color: white;
text-align: center;
color: green;
font-size: 16px;
} (a) on the left (b) in the middle (c) on the right -
32.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 400px;
justify-content: center;
}
Inside are 3 boxes, each 80px wide (no margins). - 33.📦 In the box model, which part is the gap round content? (a) content (b) margin (c) padding (d) border
-
34.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 340px;
justify-content: center;
}
Inside are 3 boxes, each 80px wide (no margins). - 35.Which of these does HTML do? (a) changes the page live (b) shows a pop-up message (c) reacts to a button click (d) makes a link
-
36.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 150px;
padding: 25px;
border: 5px solid black;
margin: 20px;
} - 37.True or false: CSS makes a link. (a) False (b) True
-
38.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
width: 300px;
text-align: center;
} - 39.🔍 Which is the odd one out? (a) makes a link (b) rounds box corners (c) makes headings and lists (d) gives the page structure
- 40.True or false: JavaScript checks a quiz answer. (a) True (b) False
Answer key
- the later one
- red
- 70
- green
- justify-content
- False
- F
- 10
- content
- <style>
- 16
- on the right
- blue
- blue
- yellow
- blue
- an id selector
- flex-start
- font-size
- /*
- 20
- bold
- 20
- True
- packs boxes at the end
- 16
- 164
- the text or picture
- 3
- 244
- in the middle
- 80
- padding
- 50
- makes a link
- 250
- False
- 2
- rounds box corners
- True
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids