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 CSS selector matches this element?
<div class="menu" id="logo">Hello</div> (a) span (b) #end (c) #menu (d) .menu -
2.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 220px;
padding: 25px;
border: 5px solid black;
margin: 10px;
} -
3.⚖️ What colour is the text of this element?
<h2 class="note" id="main">Hi</h2>
CSS:
h2 { color: white; }
.note { color: green; } (a) green (b) white (c) black (d) red - 4.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the br tag (c) the title tag (d) the viewport meta tag
-
5.✍️ What is the selector in this CSS rule?
#top {
padding: 8px;
font-size: 20px;
} (a) padding (b) 20px (c) #top (d) li - 6.What does justify-content: center do? (a) puts boxes in the middle (b) packs boxes at the start (c) packs boxes at the end (d) equal gaps, none at ends
-
7.✍️ How many declarations (property: value pairs) are in this rule?
body {
border: 2px solid;
} -
8.✍️ Which property is set to 8px in this rule?
#top {
padding: 8px;
font-size: 20px;
} (a) 8px (b) font-weight (c) padding (d) border -
9.🖌️ What colour is behind the letters?
li {
font-size: 12px;
color: blue;
text-align: left;
background-color: yellow;
} (a) orange (b) yellow (c) blue - 10.True or false: CSS changes the text size. (a) True (b) False
- 11.🎯 Can many elements share the same class? (a) No (b) Yes
- 12.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the first one (c) the later one (d) neither
- 13.🎨 One CSS file can style how many pages? (a) only one image (b) only one word (c) many pages (d) no pages
- 14.🌈 Which colour is #00ffff? (a) magenta (b) cyan (c) white (d) yellow
- 15.True or false: li is an id selector. (a) True (b) False
- 16.🎨 A CSS file usually ends with which extension? (a) .png (b) .html (c) .js (d) .css
- 17.What does font-weight do? (a) centres a heading (b) sets the letter colour (c) makes the text bold (d) colours behind the text
- 18.True or false: .star is a class selector. (a) False (b) True
-
19.⚖️ What colour is the text of this element?
<h1 class="note" id="top">Hi</h1>
CSS:
#top { color: red; }
h1 { color: orange; } (a) orange (b) red (c) purple (d) white - 20.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 4 (b) 2 (c) 6 (d) 3
-
21.⚖️ What colour is the text of this element?
<p class="big" id="top">Hi</p>
CSS:
#top { color: orange; }
#top { color: yellow; } (a) yellow (b) purple (c) orange (d) red -
22.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} -
23.✍️ What is the selector in this CSS rule?
body {
width: 300px;
background-color: yellow;
} (a) body (b) width (c) .box (d) yellow -
24.✍️ How many declarations (property: value pairs) are in this rule?
p {
background-color: yellow;
width: 300px;
} - 25.🎯 Which element does the selector p style? (a) <h1> (b) <li id="main"> (c) <p class="star"> (d) <h2 class="star">
- 26.🌈 In #00af00 the green part is the hex number af. What is it as a normal number?
-
27.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 250px;
justify-content: flex-start;
}
Inside are 3 boxes, each 80px wide (no margins). - 28.✍️ Which sign goes between a property and its value? (a) = (b) ; (c) - (d) :
-
29.🎯 Which CSS selector matches this element?
<span class="menu" id="main">Hello</span> (a) #logo (b) p (c) .menu (d) .note -
30.🎯 Which CSS selector matches this element?
<li class="note" id="intro">Hello</li> (a) div (b) .intro (c) #intro (d) .big - 31.What does justify-content: flex-end do? (a) equal gaps, none at ends (b) packs boxes at the end (c) puts boxes in the middle (d) packs boxes at the start
- 32.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) red (c) blue (d) white
-
33.⚖️ What colour is the text of this element?
<p class="star" id="logo">Hi</p>
CSS:
p { color: yellow; }
p { color: blue; } (a) orange (b) red (c) yellow (d) blue -
34.🖌️ How big is the text, in px?
h1 {
color: green;
text-align: center;
background-color: blue;
font-size: 28px;
} - 35.🌈 In #c10000 the red part is the hex number c1. What is it as a normal number?
- 36.Which of these is the content? (a) a solid or dotted edge (b) the gap round content (c) the text or picture (d) the gap to other boxes
- 37.🎯 Which sign starts a class selector? (a) . (b) @ (c) # (d) &
-
38.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 1024px) {
p {
font-size: 28px;
}
} (a) Yes (b) No - 39.🧩 Which language adds space around boxes? (a) CSS (b) JavaScript (c) HTML
- 40.✍️ In color: blue; which part is the property? (a) color (b) : (c) ; (d) blue
Answer key
- .menu
- 300
- green
- the viewport meta tag
- #top
- puts boxes in the middle
- 1
- padding
- yellow
- True
- Yes
- the later one
- many pages
- cyan
- False
- .css
- makes the text bold
- True
- red
- 3
- yellow
- 10
- body
- 2
- <p class="star">
- 175
- 10
- :
- .menu
- #intro
- packs boxes at the end
- blue
- blue
- 28
- 193
- the text or picture
- .
- No
- CSS
- color
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids