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.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
text-align: center;
color: red;
font-weight: bold;
padding: 8px;
} - 2.True or false: the border is space inside the border. (a) True (b) False
- 3.🌈 Which colour is #00ffff? (a) yellow (b) white (c) cyan (d) red
-
4.✍️ How many declarations (property: value pairs) are in this rule?
body {
text-align: center;
font-size: 20px;
color: red;
font-style: italic;
} - 5.🌈 Which colour is rgb(0, 0, 0)? (a) red (b) black (c) magenta (d) cyan
- 6.🖌️ Which CSS property makes the text bold? (a) background-color (b) font-family (c) font-weight (d) font-size
- 7.✍️ In color: blue; which part is the property? (a) : (b) blue (c) ; (d) color
-
8.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 18px;
}
} - 9.📱 What does a media query check? (a) the time of day (b) the screen width (c) the page title (d) the battery level
- 10.✍️ CSS declarations go inside which brackets? (a) ( ) (b) [ ] (c) { } (d) < >
-
11.⚖️ What colour is the text of this element?
<h1 class="menu" id="top">Hi</h1>
CSS:
h1 { color: green; }
#top { color: yellow; }
.menu { color: red; } (a) green (b) red (c) yellow (d) blue - 12.🎯 Which sign starts a class selector? (a) @ (b) # (c) & (d) .
- 13.🔍 Which is the odd one out? (a) gives the page structure (b) shows a pop-up message (c) makes headings and lists (d) makes a link
- 14.What does justify-content: center do? (a) packs boxes at the end (b) packs boxes at the start (c) puts boxes in the middle (d) equal gaps, none at ends
-
15.✍️ What is the selector in this CSS rule?
#top {
width: 300px;
font-size: 20px;
font-weight: bold;
text-align: center;
} (a) 20px (b) li (c) #top (d) width -
16.🎯 Which CSS selector matches this element?
<h2 class="big" id="hero">Hello</h2> (a) #hero (b) .hero (c) #top (d) #big -
17.🖌️ How big is the text, in px?
h2 {
text-align: left;
background-color: purple;
color: green;
font-size: 28px;
} -
18.⚖️ What colour is the text of this element?
<h1 class="menu" id="main">Hi</h1>
CSS:
h1 { color: black; }
h1 { color: yellow; } (a) green (b) black (c) red (d) yellow -
19.⚖️ What colour is the text of this element?
<p class="menu" id="end">Hi</p>
CSS:
.menu { color: purple; }
#end { color: black; }
p { color: blue; } (a) purple (b) red (c) black (d) blue - 20.🌈 Which hex code is red? (a) #ff00ff (b) #00ffff (c) #0000ff (d) #ff0000
- 21.🎯 Which sign starts an id selector? (a) # (b) & (c) @ (d) .
- 22.True or false: li is an element selector. (a) True (b) False
- 23.🎯 What kind of selector is .card? (a) an id selector (b) a class selector (c) an element selector
-
24.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
text-align: center;
font-weight: bold;
font-size: 20px;
} -
25.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 16px;
}
} -
26.✍️ What value is given to font-size in this rule?
p {
font-size: 20px;
font-weight: bold;
} (a) 20px (b) font-size (c) center (d) yellow - 27.🌈 Which colour is #ff00ff? (a) white (b) red (c) black (d) magenta
-
28.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 200px;
padding: 20px;
border: 5px solid black;
margin: 15px;
} -
29.⚖️ What colour is the text of this element?
<h1 class="box" id="top">Hi</h1>
CSS:
.box { color: black; }
#top { color: white; }
h1 { color: red; } (a) black (b) red (c) white (d) orange - 30.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
- 31.What does font-size do? (a) makes letters bigger (b) colours behind the text (c) picks the font style (d) sets the letter colour
-
32.⚖️ What colour is the text of this element?
<h2 class="red" id="end">Hi</h2>
CSS:
.red { color: white; }
#end { color: red; }
h2 { color: orange; } (a) red (b) black (c) orange (d) white - 33.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the br tag (c) the viewport meta tag (d) the hr tag
- 34.True or false: .card is an id selector. (a) False (b) True
- 35.📦 In the box model, which part is the gap round content? (a) padding (b) content (c) border (d) margin
-
36.🎯 Which CSS selector matches this element?
<li class="big" id="main">Hello</li> (a) li (b) #big (c) #logo (d) .main -
37.✍️ What value is given to background-color in this rule?
h1 {
background-color: yellow;
border: 2px solid;
} (a) 10px (b) background-color (c) yellow (d) 8px - 38.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) white (c) green (d) blue
-
39.🖌️ Where does the text sit on its line?
p {
font-size: 36px;
background-color: yellow;
text-align: left;
color: blue;
} (a) on the left (b) on the right (c) in the middle -
40.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 220px;
justify-content: flex-end;
}
Inside are 4 boxes, each 50px wide (no margins).
Answer key
- 4
- False
- cyan
- 4
- black
- font-weight
- color
- 18
- the screen width
- { }
- yellow
- .
- shows a pop-up message
- puts boxes in the middle
- #top
- #hero
- 28
- yellow
- black
- #ff0000
- #
- True
- a class selector
- 3
- 12
- 20px
- magenta
- 280
- white
- an element selector
- makes letters bigger
- red
- the viewport meta tag
- False
- padding
- li
- yellow
- blue
- on the left
- 20
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids