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 value is given to text-align in this rule?
li {
border: 2px solid;
text-align: center;
} (a) 10px (b) text-align (c) center (d) yellow -
2.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 12px;
}
} - 3.🌈 In #00008a the blue part is the hex number 8a. What is it as a normal number?
-
4.🖌️ What colour are the letters?
h1 {
background-color: orange;
text-align: right;
color: green;
font-size: 40px;
} (a) green (b) blue (c) orange -
5.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 180px;
padding: 30px;
border: 4px solid black;
margin: 5px;
} - 6.What does justify-content: center do? (a) puts boxes in the middle (b) equal gaps, none at ends (c) packs boxes at the start (d) packs boxes at the end
-
7.⚖️ What colour is the text of this element?
<h1 class="menu" id="logo">Hi</h1>
CSS:
h1 { color: red; }
#logo { color: purple; } (a) red (b) orange (c) purple (d) white - 8.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
- 9.🌈 Which colour is #ff0000? (a) magenta (b) yellow (c) black (d) red
- 10.🎯 Which element does the selector h1 style? (a) <div id="top"> (b) <h2> (c) <li class="menu"> (d) <h1 class="menu">
- 11.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) gap (c) justify-content (d) display: flex
- 12.✍️ Which sign goes between a property and its value? (a) - (b) ; (c) : (d) =
- 13.🎯 Which element does the selector li style? (a) <li class="red"> (b) <div> (c) <span class="red"> (d) <p id="logo">
- 14.📱 Responsive design means a page ___. (a) is only for laptops (b) fits every screen (c) never changes (d) has no pictures
- 15.⚖️ Which selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
-
16.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 24px;
}
} (a) Yes (b) No -
17.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 16px;
}
} (a) Yes (b) No -
18.⚖️ What colour is the text of this element?
<p class="box" id="logo">Hi</p>
CSS:
p { color: black; }
p { color: red; } (a) white (b) black (c) red (d) orange - 19.Which of these is padding? (a) the gap to other boxes (b) a solid or dotted edge (c) space inside the border (d) the line round the box
-
20.⚖️ What colour is the text of this element?
<p class="box" id="top">Hi</p>
CSS:
.box { color: yellow; }
.box { color: purple; } (a) white (b) yellow (c) red (d) purple -
21.🎯 Which CSS selector matches this element?
<p class="menu" id="end">Hello</p> (a) #menu (b) .note (c) #end (d) .end - 22.✍️ How does a CSS comment start? (a) <!-- (b) // (c) /* (d) #
-
23.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 240px;
padding: 15px;
border: 4px solid black;
margin: 0px;
} -
24.🖌️ Where does the text sit on its line?
h2 {
font-size: 36px;
text-align: right;
color: blue;
background-color: black;
} (a) in the middle (b) on the left (c) on the right - 25.🧩 Which language puts a picture on a page? (a) JavaScript (b) CSS (c) HTML
- 26.🎯 Which element does the selector .red style? (a) <li class="star"> (b) <h2 class="red"> (c) <h2 class="box"> (d) <h2 id="red">
-
27.⚖️ What colour is the text of this element?
<p class="big" id="top">Hi</p>
CSS:
#top { color: yellow; }
#top { color: red; } (a) green (b) red (c) yellow (d) orange -
28.✍️ What value is given to background-color in this rule?
body {
background-color: yellow;
border: 2px solid;
width: 300px;
} (a) background-color (b) yellow (c) 8px (d) 10px -
29.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 600px) {
p {
font-size: 28px;
}
} (a) No (b) Yes -
30.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 10px;
}
} - 31.Which of these does HTML do? (a) gives the page structure (b) changes the text size (c) changes the page live (d) lays out the page
-
32.✍️ How many declarations (property: value pairs) are in this rule?
p {
text-align: center;
margin: 10px;
font-style: italic;
background-color: yellow;
} - 33.💪 Which justify-content value packs boxes at the start? (a) center (b) flex-end (c) space-between (d) flex-start
-
34.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 22px;
}
} - 35.💪 Which flexbox property sets space between boxes? (a) display: flex (b) gap (c) align-items (d) flex-direction
-
36.🎯 Which CSS selector matches this element?
<div class="box" id="top">Hello</div> (a) .box (b) #box (c) .top (d) .star -
37.🎯 Which CSS selector matches this element?
<h2 class="red" id="hero">Hello</h2> (a) .red (b) .box (c) .hero (d) li -
38.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 6px;
}
} (a) No (b) Yes - 39.True or false: CSS counts down a timer. (a) True (b) False
-
40.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 20px;
}
} (a) Yes (b) No
Answer key
- center
- 12
- 138
- green
- 258
- puts boxes in the middle
- purple
- an element selector
- red
- <h1 class="menu">
- display: flex
- :
- <li class="red">
- fits every screen
- an id selector
- Yes
- Yes
- red
- space inside the border
- purple
- #end
- /*
- 278
- on the right
- HTML
- <h2 class="red">
- red
- yellow
- Yes
- 10
- gives the page structure
- 4
- flex-start
- 24
- gap
- .box
- .red
- No
- False
- No
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids