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 colour is behind the letters?
p {
text-align: center;
font-size: 20px;
color: red;
background-color: purple;
} (a) red (b) green (c) purple - 2.What does justify-content: flex-start do? (a) packs boxes at the start (b) packs boxes at the end (c) puts boxes in the middle (d) equal gaps, none at ends
- 3.💪 Which flexbox property sets space between boxes? (a) flex-direction (b) display: flex (c) justify-content (d) gap
- 4.💪 Which flexbox property turns on flexbox? (a) display: flex (b) justify-content (c) align-items (d) flex-direction
-
5.✍️ Which property is set to 300px in this rule?
.box {
width: 300px;
margin: 10px;
} (a) 300px (b) width (c) font-style (d) color -
6.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 150px;
justify-content: flex-start;
}
Inside are 2 boxes, each 60px wide (no margins). - 7.True or false: HTML puts a picture on a page. (a) True (b) False
-
8.⚖️ What colour is the text of this element?
<p class="star" id="end">Hi</p>
CSS:
#end { color: black; }
.star { color: purple; } (a) purple (b) green (c) white (d) black -
9.🖌️ Where does the text sit on its line?
h1 {
text-align: center;
font-size: 36px;
color: yellow;
background-color: purple;
} (a) on the left (b) in the middle (c) on the right - 10.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
-
11.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 140px;
padding: 10px;
border: 1px solid black;
margin: 20px;
} -
12.⚖️ What colour is the text of this element?
<p class="star" id="end">Hi</p>
CSS:
#end { color: purple; }
#end { color: green; } (a) purple (b) yellow (c) green (d) blue -
13.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
border: 2px solid;
color: red;
} -
14.✍️ What is the selector in this CSS rule?
p {
margin: 10px;
width: 300px;
border: 2px solid;
} (a) margin (b) 300px (c) p (d) .note - 15.True or false: li is an id selector. (a) True (b) False
- 16.✍️ CSS declarations go inside which brackets? (a) [ ] (b) ( ) (c) < > (d) { }
- 17.🌈 Which colour is #00ff00? (a) red (b) white (c) magenta (d) bright green
- 18.🔍 Which is the odd one out? (a) shows a pop-up message (b) makes headings and lists (c) puts a picture on a page (d) makes a link
-
19.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
font-size: 20px;
font-style: italic;
} - 20.🌈 Which colour is rgb(0, 255, 0)? (a) magenta (b) black (c) bright green (d) blue
- 21.✍️ In color: blue; which part is the value? (a) color (b) blue (c) : (d) ;
-
22.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 150px;
padding: 30px;
border: 3px solid black;
margin: 5px;
} - 23.✍️ Which sign goes between a property and its value? (a) ; (b) = (c) - (d) :
- 24.🌈 In #00006f the blue part is the hex number 6f. What is it as a normal number?
-
25.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 130px;
padding: 10px;
border: 1px solid black;
margin: 20px;
} - 26.🖌️ Which CSS property centres a heading? (a) background-color (b) text-align (c) font-weight (d) font-family
- 27.📱 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
-
28.✍️ Which property is set to 300px in this rule?
.note {
margin: 10px;
width: 300px;
} (a) 300px (b) font-style (c) color (d) width -
29.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 24px;
}
} (a) No (b) Yes - 30.🌈 Which colour is #00ffff? (a) magenta (b) white (c) red (d) cyan
-
31.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 140px;
padding: 30px;
border: 2px solid black;
margin: 15px;
} -
32.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 8px;
}
} -
33.✍️ How many declarations (property: value pairs) are in this rule?
li {
border: 2px solid;
} -
34.🖌️ How big is the text, in px?
p {
color: blue;
background-color: yellow;
font-size: 40px;
text-align: left;
} - 35.What does justify-content: flex-end do? (a) packs boxes at the end (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the start
-
36.⚖️ What colour is the text of this element?
<p class="big" id="hero">Hi</p>
CSS:
#hero { color: red; }
.big { color: orange; } (a) purple (b) red (c) yellow (d) orange -
37.🖌️ Where does the text sit on its line?
li {
text-align: left;
font-size: 36px;
color: green;
background-color: black;
} (a) on the left (b) on the right (c) in the middle -
38.🖌️ What colour are the letters?
h1 {
background-color: blue;
text-align: right;
font-size: 28px;
color: red;
} (a) blue (b) yellow (c) red -
39.⚖️ What colour is the text of this element?
<h1 class="star" id="end">Hi</h1>
CSS:
#end { color: black; }
.star { color: yellow; } (a) yellow (b) blue (c) red (d) black - 40.🌈 Which colour is rgb(255, 0, 0)? (a) red (b) blue (c) black (d) bright green
Answer key
- purple
- packs boxes at the start
- gap
- display: flex
- width
- 30
- True
- black
- in the middle
- an id selector
- 162
- green
- 2
- p
- False
- { }
- bright green
- shows a pop-up message
- 2
- bright green
- blue
- 226
- :
- 111
- 152
- text-align
- the viewport meta tag
- width
- No
- cyan
- 234
- 12
- 1
- 40
- packs boxes at the end
- red
- on the left
- red
- black
- red
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids