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.🌈 Which colour of light is strongest in rgb(218, 1, 32)? (a) green (b) blue (c) red
-
2.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 14px;
}
} - 3.What does background-color do? (a) makes letters bigger (b) picks the font style (c) sets the letter colour (d) colours behind the text
- 4.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 4 (b) 6 (c) 2 (d) 3
-
5.✍️ Which property is set to 2px solid in this rule?
.box {
border: 2px solid;
padding: 8px;
} (a) width (b) 2px solid (c) font-style (d) border -
6.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 14px;
}
} -
7.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
border: 2px solid;
font-weight: bold;
} -
8.⚖️ What colour is the text of this element?
<p class="note" id="main">Hi</p>
CSS:
p { color: yellow; }
#main { color: white; }
.note { color: purple; } (a) white (b) orange (c) yellow (d) purple - 9.What does justify-content: space-between do? (a) puts boxes in the middle (b) packs boxes at the end (c) equal gaps, none at ends (d) packs boxes at the start
-
10.⚖️ What colour is the text of this element?
<p class="box" id="end">Hi</p>
CSS:
#end { color: black; }
p { color: blue; } (a) green (b) blue (c) black (d) purple - 11.📦 In the box model, which part is the line round the box? (a) border (b) content (c) margin (d) padding
- 12.🖌️ Which CSS property sets the letter colour? (a) text-align (b) font-size (c) color (d) font-family
- 13.True or false: .star is a class selector. (a) False (b) True
-
14.🖌️ Where does the text sit on its line?
h2 {
background-color: green;
color: yellow;
font-size: 40px;
text-align: right;
} (a) on the left (b) on the right (c) in the middle - 15.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) blue (c) black (d) red
- 16.🧩 Which language gives the page structure? (a) JavaScript (b) CSS (c) HTML
- 17.What does font-weight do? (a) makes the text bold (b) centres a heading (c) sets the letter colour (d) makes letters bigger
- 18.True or false: #end is an element selector. (a) True (b) False
-
19.⚖️ What colour is the text of this element?
<p class="menu" id="logo">Hi</p>
CSS:
.menu { color: red; }
#logo { color: purple; }
p { color: green; } (a) purple (b) orange (c) green (d) red -
20.🖌️ What colour is behind the letters?
h1 {
background-color: red;
color: white;
text-align: left;
font-size: 24px;
} (a) red (b) blue (c) white - 21.True or false: .menu is an id selector. (a) True (b) False
-
22.🖌️ What colour are the letters?
h2 {
text-align: right;
font-size: 24px;
background-color: green;
color: orange;
} (a) green (b) orange (c) black -
23.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 24px;
}
} -
24.⚖️ What colour is the text of this element?
<h1 class="big" id="hero">Hi</h1>
CSS:
h1 { color: black; }
.big { color: orange; } (a) orange (b) red (c) black (d) green -
25.🎯 Which CSS selector matches this element?
<h1 class="note" id="logo">Hello</h1> (a) #end (b) h2 (c) .logo (d) h1 -
26.✍️ Which property is set to 8px in this rule?
#top {
padding: 8px;
font-style: italic;
width: 300px;
font-size: 20px;
} (a) border (b) padding (c) font-weight (d) 8px - 27.🎨 What does CSS stand for? (a) Computer Style Sheets (b) Creative Sheet System (c) Cascading Style Sheets (d) Colourful Site Styles
- 28.True or false: padding is the text or picture. (a) False (b) True
- 29.💪 Which flexbox property spaces boxes along a row? (a) justify-content (b) display: flex (c) align-items (d) flex-direction
-
30.🖌️ How big is the text, in px?
h1 {
background-color: purple;
text-align: left;
color: yellow;
font-size: 28px;
} -
31.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 60px;
padding: 15px;
border: 4px solid black;
margin: 20px;
} -
32.🎯 Which CSS selector matches this element?
<li class="menu" id="hero">Hello</li> (a) .note (b) div (c) .menu (d) .hero - 33.⚖️ Which selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
-
34.🖌️ Where does the text sit on its line?
h2 {
color: yellow;
text-align: center;
background-color: purple;
font-size: 28px;
} (a) on the right (b) in the middle (c) on the left - 35.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
- 36.✍️ Which sign goes between a property and its value? (a) = (b) - (c) ; (d) :
- 37.🎯 Which element does the selector p style? (a) <h2 class="red"> (b) <p class="red"> (c) <h1> (d) <li id="main">
-
38.⚖️ What colour is the text of this element?
<h2 class="menu" id="top">Hi</h2>
CSS:
h2 { color: yellow; }
.menu { color: purple; }
#top { color: white; } (a) white (b) black (c) purple (d) yellow -
39.🖌️ How big is the text, in px?
h1 {
font-size: 28px;
text-align: center;
background-color: orange;
color: white;
} -
40.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 140px;
padding: 25px;
border: 2px solid black;
margin: 0px;
}
Answer key
- red
- 14
- colours behind the text
- 3
- border
- 14
- 2
- white
- equal gaps, none at ends
- black
- border
- color
- True
- on the right
- red
- HTML
- makes the text bold
- False
- purple
- red
- False
- orange
- 20
- orange
- h1
- padding
- Cascading Style Sheets
- False
- justify-content
- 28
- 138
- .menu
- an id selector
- in the middle
- packs boxes at the start
- :
- <p class="red">
- white
- 28
- 194
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids