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 much space top to bottom (px) does this box take in all, margin included?
.box {
height: 130px;
padding: 15px;
border: 5px solid black;
margin: 5px;
} - 2.Which of these is padding? (a) space outside the border (b) space inside the border (c) the text or picture (d) the line round the box
-
3.🎯 Which CSS selector matches this element?
<li class="note" id="hero">Hello</li> (a) .big (b) div (c) #top (d) li - 4.True or false: CSS sets colours and fonts. (a) False (b) True
- 5.📦 In the box model, which part is the gap to other boxes? (a) padding (b) content (c) border (d) margin
- 6.📦 In the box model, which part is a solid or dotted edge? (a) border (b) margin (c) content (d) padding
-
7.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 20px;
}
} - 8.🧩 Which language lays out the page? (a) HTML (b) JavaScript (c) CSS
- 9.🎯 Can many elements share the same class? (a) Yes (b) No
-
10.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 10px;
}
} -
11.⚖️ What colour is the text of this element?
<p class="big" id="intro">Hi</p>
CSS:
p { color: white; }
.big { color: purple; }
#intro { color: red; } (a) black (b) purple (c) red (d) white - 12.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
-
13.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 120px;
padding: 20px;
border: 1px solid black;
margin: 10px;
} -
14.⚖️ What colour is the text of this element?
<p class="big" id="main">Hi</p>
CSS:
.big { color: red; }
#main { color: white; } (a) red (b) white (c) blue (d) green - 15.💪 Which flexbox property spaces boxes along a row? (a) display: flex (b) flex-direction (c) gap (d) justify-content
-
16.✍️ What is the selector in this CSS rule?
#top {
background-color: yellow;
border: 2px solid;
padding: 8px;
} (a) background-color (b) #top (c) 2px solid (d) li - 17.💪 Which justify-content value packs boxes at the end? (a) flex-end (b) flex-start (c) center (d) space-between
-
18.✍️ Which property is set to yellow in this rule?
li {
padding: 8px;
background-color: yellow;
font-style: italic;
width: 300px;
} (a) margin (b) background-color (c) yellow (d) padding -
19.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 8px;
}
} (a) No (b) Yes - 20.True or false: the border is the gap round content. (a) False (b) True
- 21.True or false: .menu is an id selector. (a) True (b) False
- 22.🌈 Which hex code is yellow? (a) #000000 (b) #ffff00 (c) #0000ff (d) #ffffff
- 23.✍️ How does a CSS comment start? (a) # (b) <!-- (c) // (d) /*
-
24.🎯 Which CSS selector matches this element?
<span class="star" id="top">Hello</span> (a) p (b) .menu (c) .top (d) #top -
25.⚖️ What colour is the text of this element?
<p class="note" id="intro">Hi</p>
CSS:
#intro { color: purple; }
#intro { color: yellow; } (a) white (b) yellow (c) purple (d) blue -
26.⚖️ What colour is the text of this element?
<h1 class="note" id="top">Hi</h1>
CSS:
#top { color: red; }
h1 { color: yellow; }
.note { color: green; } (a) yellow (b) white (c) green (d) red - 27.True or false: HTML makes a form box. (a) False (b) True
- 28.🌈 Which colour is #ff0000? (a) yellow (b) blue (c) red (d) bright green
- 29.💪 Which flexbox property lines boxes up across? (a) align-items (b) gap (c) display: flex (d) flex-direction
- 30.🔍 Which is the odd one out? (a) gives the page structure (b) makes a link (c) reacts to a button click (d) puts a picture on a page
-
31.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 280px;
padding: 5px;
border: 1px solid black;
margin: 15px;
} -
32.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 16px;
}
} (a) No (b) Yes - 33.🌈 Which hex code is bright green? (a) #ff0000 (b) #0000ff (c) #00ff00 (d) #ffff00
- 34.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the title tag (c) the br tag (d) the viewport meta tag
- 35.✍️ Which sign goes between a property and its value? (a) - (b) = (c) : (d) ;
-
36.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-weight: bold;
} - 37.🎨 A CSS file usually ends with which extension? (a) .js (b) .html (c) .css (d) .png
- 38.True or false: body is a class selector. (a) True (b) False
-
39.🖌️ What colour are the letters?
h1 {
font-size: 28px;
background-color: green;
text-align: right;
color: blue;
} (a) red (b) green (c) blue - 40.True or false: CSS makes a form box. (a) True (b) False
Answer key
- 180
- space inside the border
- li
- True
- margin
- border
- 20
- CSS
- Yes
- 10
- red
- an element selector
- 182
- white
- justify-content
- #top
- flex-end
- background-color
- Yes
- False
- False
- #ffff00
- /*
- #top
- yellow
- red
- True
- red
- align-items
- reacts to a button click
- 292
- No
- #00ff00
- the viewport meta tag
- :
- 1
- .css
- False
- blue
- False
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids