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 does color do? (a) centres a heading (b) picks the font style (c) sets the letter colour (d) makes letters bigger
-
2.✍️ What is the selector in this CSS rule?
.note {
padding: 8px;
border: 2px solid;
} (a) #top (b) 2px solid (c) padding (d) .note -
3.✍️ What is the selector in this CSS rule?
p {
font-style: italic;
font-weight: bold;
font-size: 20px;
color: red;
} (a) bold (b) .note (c) p (d) font-style - 4.🌈 In #160000 the red part is the hex number 16. What is it as a normal number?
- 5.True or false: .card is a class selector. (a) False (b) True
-
6.⚖️ What colour is the text of this element?
<h1 class="note" id="logo">Hi</h1>
CSS:
h1 { color: blue; }
#logo { color: purple; }
.note { color: black; } (a) purple (b) black (c) orange (d) blue - 7.True or false: padding is the gap round content. (a) True (b) False
-
8.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
color: red;
} - 9.🎯 Which element does the selector #hero style? (a) <p id="top"> (b) <h1 class="menu"> (c) <p id="hero"> (d) <p class="hero">
- 10.🎯 What kind of selector is #main? (a) a class selector (b) an id selector (c) an element selector
-
11.🎯 Which CSS selector matches this element?
<h2 class="star" id="main">Hello</h2> (a) h2 (b) .main (c) #logo (d) #star - 12.🌈 In #380000 the red part is the hex number 38. What is it as a normal number?
- 13.💪 Which flexbox property turns on flexbox? (a) gap (b) display: flex (c) justify-content (d) flex-direction
-
14.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 8px;
}
} - 15.📦 In the box model, which part is the gap round content? (a) padding (b) content (c) margin (d) border
- 16.🧩 Which language makes a link? (a) HTML (b) CSS (c) JavaScript
- 17.True or false: the border is the line round the box. (a) True (b) False
-
18.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 160px;
padding: 20px;
border: 2px solid black;
margin: 20px;
} - 19.True or false: li is a class selector. (a) False (b) True
- 20.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
- 21.🎯 How many elements on a page should have the same id? (a) 5 (b) 1 (c) any number (d) 2
-
22.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 50px;
padding: 15px;
border: 5px solid black;
margin: 0px;
} - 23.📱 What does a media query check? (a) the screen width (b) the time of day (c) the battery level (d) the page title
-
24.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 22px;
}
} (a) Yes (b) No - 25.🧩 Which language changes the page live? (a) JavaScript (b) HTML (c) CSS
-
26.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 1024px) {
p {
font-size: 26px;
}
} (a) Yes (b) No - 27.🎯 Which element does the selector .box style? (a) <h2 class="star"> (b) <h2 id="box"> (c) <li class="menu"> (d) <h2 class="box">
- 28.🎯 Which element does the selector span style? (a) <h2 id="main"> (b) <p> (c) <span class="note"> (d) <h1 class="note">
-
29.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 110px;
justify-content: flex-start;
}
Inside are 2 boxes, each 50px wide (no margins). -
30.⚖️ What colour is the text of this element?
<h1 class="star" id="top">Hi</h1>
CSS:
h1 { color: white; }
h1 { color: purple; } (a) purple (b) blue (c) white (d) red - 31.📦 In the box model, which part is space inside the border? (a) margin (b) content (c) padding (d) border
-
32.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 28px;
}
} (a) No (b) Yes - 33.🌈 Which colour is rgb(0, 255, 255)? (a) blue (b) white (c) red (d) cyan
- 34.🎯 Which sign starts a class selector? (a) @ (b) & (c) . (d) #
- 35.🎨 A CSS file usually ends with which extension? (a) .css (b) .js (c) .html (d) .png
- 36.🌈 Hex digits go 0 to 9, then A to which letter? (a) G (b) J (c) Z (d) F
- 37.🧩 Which language changes the text size? (a) JavaScript (b) CSS (c) HTML
-
38.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 8px;
}
} (a) Yes (b) No - 39.True or false: img is an element selector. (a) True (b) False
- 40.💪 Which justify-content value packs boxes at the start? (a) center (b) flex-end (c) space-between (d) flex-start
Answer key
- sets the letter colour
- .note
- p
- 22
- True
- purple
- True
- 1
- <p id="hero">
- an id selector
- h2
- 56
- display: flex
- 8
- padding
- HTML
- True
- 204
- False
- an id selector
- 1
- 90
- the screen width
- Yes
- JavaScript
- No
- <h2 class="box">
- <span class="note">
- 10
- purple
- padding
- No
- cyan
- .
- .css
- F
- CSS
- No
- True
- flex-start
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids