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 the text of this element?
<h2 class="red" id="top">Hi</h2>
CSS:
h2 { color: white; }
.red { color: green; }
#top { color: black; } (a) red (b) green (c) black (d) white - 2.🎨 What does CSS stand for? (a) Cascading Style Sheets (b) Colourful Site Styles (c) Creative Sheet System (d) Computer Style Sheets
-
3.✍️ What is the selector in this CSS rule?
h2 {
text-align: center;
background-color: yellow;
} (a) text-align (b) h1 (c) h2 (d) yellow -
4.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
padding: 8px;
margin: 10px;
} - 5.Which of these is the content? (a) the line round the box (b) space inside the border (c) the gap to other boxes (d) the text or picture
-
6.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 28px;
}
} -
7.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 600px) {
p {
font-size: 22px;
}
} -
8.⚖️ What colour is the text of this element?
<p class="box" id="intro">Hi</p>
CSS:
.box { color: black; }
p { color: green; }
#intro { color: orange; } (a) black (b) green (c) orange (d) red - 9.✍️ Which sign goes between a property and its value? (a) - (b) : (c) ; (d) =
-
10.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 140px;
justify-content: center;
}
Inside are 2 boxes, each 40px wide (no margins). - 11.What does justify-content: flex-end do? (a) packs boxes at the start (b) packs boxes at the end (c) equal gaps, none at ends (d) puts boxes in the middle
- 12.🌈 Which hex code is black? (a) #0000ff (b) #00ff00 (c) #000000 (d) #ffffff
-
13.✍️ What value is given to border in this rule?
body {
border: 2px solid;
font-style: italic;
} (a) italic (b) 2px solid (c) 300px (d) border - 14.💪 Which flexbox property sets space between boxes? (a) flex-direction (b) justify-content (c) gap (d) display: flex
- 15.🌈 Which colour is #0000ff? (a) bright green (b) blue (c) white (d) red
- 16.What does background-color do? (a) makes letters bigger (b) centres a heading (c) sets the letter colour (d) colours behind the text
- 17.🌈 Which colour is #000000? (a) red (b) bright green (c) blue (d) black
-
18.🖌️ What colour is behind the letters?
h1 {
color: blue;
text-align: left;
font-size: 12px;
background-color: purple;
} (a) blue (b) purple (c) black - 19.🎯 What kind of selector is body? (a) an element selector (b) a class selector (c) an id selector
-
20.⚖️ What colour is the text of this element?
<h1 class="red" id="logo">Hi</h1>
CSS:
#logo { color: black; }
.red { color: yellow; } (a) yellow (b) blue (c) black (d) orange - 21.🖌️ Which CSS property makes letters bigger? (a) color (b) text-align (c) font-size (d) font-family
-
22.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 1024px) {
p {
font-size: 22px;
}
} - 23.🔍 Which is the odd one out? (a) makes a link (b) rounds box corners (c) puts a picture on a page (d) gives the page structure
- 24.🖌️ Which CSS property colours behind the text? (a) background-color (b) color (c) font-weight (d) font-family
- 25.🎯 What kind of selector is p? (a) a class selector (b) an id selector (c) an element selector
- 26.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the first one (c) neither (d) the later one
-
27.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 130px;
justify-content: space-between;
}
Inside are 2 boxes, each 60px wide (no margins). -
28.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 1024px) {
p {
font-size: 18px;
}
} (a) No (b) Yes -
29.🖌️ Where does the text sit on its line?
h2 {
text-align: right;
font-size: 36px;
background-color: purple;
color: black;
} (a) on the right (b) on the left (c) in the middle -
30.⚖️ What colour is the text of this element?
<p class="red" id="logo">Hi</p>
CSS:
.red { color: green; }
p { color: black; } (a) black (b) blue (c) white (d) green - 31.🌈 Which colour is rgb(0, 0, 255)? (a) red (b) blue (c) black (d) bright green
- 32.What does justify-content: flex-start do? (a) packs boxes at the start (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the end
-
33.✍️ What value is given to font-style in this rule?
h1 {
font-style: italic;
text-align: center;
font-size: 20px;
} (a) font-style (b) italic (c) red (d) 20px -
34.✍️ How many declarations (property: value pairs) are in this rule?
li {
font-size: 20px;
border: 2px solid;
font-style: italic;
} - 35.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
- 36.True or false: img is an id selector. (a) False (b) True
-
37.✍️ How many declarations (property: value pairs) are in this rule?
#top {
border: 2px solid;
} - 38.🎯 Can many elements share the same class? (a) No (b) Yes
- 39.True or false: the content is a solid or dotted edge. (a) True (b) False
-
40.✍️ What is the selector in this CSS rule?
p {
font-size: 20px;
color: red;
padding: 8px;
} (a) font-size (b) .note (c) red (d) p
Answer key
- black
- Cascading Style Sheets
- h2
- 2
- the text or picture
- 28
- 20
- orange
- :
- 30
- packs boxes at the end
- #000000
- 2px solid
- gap
- blue
- colours behind the text
- black
- purple
- an element selector
- black
- font-size
- 22
- rounds box corners
- background-color
- an element selector
- the later one
- 10
- No
- on the right
- green
- blue
- packs boxes at the start
- italic
- 3
- an id selector
- False
- 1
- Yes
- False
- p
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids