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.🖌️ Where does the text sit on its line?
h1 {
color: black;
font-size: 20px;
background-color: purple;
text-align: center;
} (a) on the left (b) in the middle (c) on the right - 2.🌈 Which hex code is black? (a) #000000 (b) #0000ff (c) #ff00ff (d) #00ff00
-
3.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 14px;
}
} -
4.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} - 5.✍️ How does a CSS comment start? (a) // (b) <!-- (c) # (d) /*
- 6.🌈 Which colour is rgb(255, 255, 255)? (a) magenta (b) bright green (c) red (d) white
-
7.⚖️ What colour is the text of this element?
<p class="note" id="end">Hi</p>
CSS:
p { color: purple; }
p { color: yellow; } (a) purple (b) yellow (c) green (d) white - 8.🌈 In #rrggbb, which colour do the first two digits give? (a) blue (b) green (c) red (d) black
-
9.🖌️ What colour are the letters?
h1 {
text-align: center;
font-size: 20px;
background-color: orange;
color: blue;
} (a) blue (b) orange (c) white -
10.✍️ What value is given to font-style in this rule?
h1 {
font-size: 20px;
background-color: yellow;
font-style: italic;
color: red;
} (a) italic (b) red (c) 20px (d) font-style - 11.🎯 Which element does the selector li style? (a) <li class="big"> (b) <div> (c) <p id="end"> (d) <span class="big">
- 12.📱 Responsive design means a page ___. (a) never changes (b) has no pictures (c) is only for laptops (d) fits every screen
- 13.🧩 Which language makes a link? (a) JavaScript (b) HTML (c) CSS
-
14.🎯 Which CSS selector matches this element?
<span class="box" id="hero">Hello</span> (a) #box (b) .star (c) .hero (d) span -
15.⚖️ What colour is the text of this element?
<h1 class="menu" id="main">Hi</h1>
CSS:
.menu { color: blue; }
.menu { color: yellow; } (a) red (b) blue (c) green (d) yellow -
16.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
color: red;
background-color: yellow;
width: 300px;
font-size: 20px;
} - 17.True or false: the border is a solid or dotted edge. (a) False (b) True
-
18.✍️ Which property is set to 2px solid in this rule?
h1 {
width: 300px;
color: red;
font-weight: bold;
border: 2px solid;
} (a) 2px solid (b) width (c) font-style (d) border -
19.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 40px;
padding: 30px;
border: 4px solid black;
margin: 10px;
} - 20.🎯 Which element does the selector span style? (a) <span class="note"> (b) <p> (c) <h2 id="main"> (d) <h1 class="note">
- 21.💪 Which flexbox property picks row or column? (a) align-items (b) display: flex (c) flex-direction (d) justify-content
- 22.✍️ In color: blue; which part is the property? (a) blue (b) ; (c) color (d) :
- 23.Which of these does CSS do? (a) checks a quiz answer (b) counts down a timer (c) sets colours and fonts (d) gives the page structure
- 24.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
-
25.⚖️ What colour is the text of this element?
<p class="menu" id="logo">Hi</p>
CSS:
p { color: blue; }
.menu { color: purple; }
#logo { color: orange; } (a) green (b) blue (c) purple (d) orange - 26.Which of these does HTML do? (a) makes headings and lists (b) changes the page live (c) reacts to a button click (d) adds space around boxes
-
27.⚖️ What colour is the text of this element?
<p class="big" id="hero">Hi</p>
CSS:
.big { color: red; }
#hero { color: yellow; }
p { color: green; } (a) red (b) orange (c) yellow (d) green -
28.✍️ What is the selector in this CSS rule?
h1 {
margin: 10px;
border: 2px solid;
text-align: center;
} (a) margin (b) 2px solid (c) p (d) h1 - 29.🌈 Which colour is #00ffff? (a) black (b) blue (c) bright green (d) cyan
- 30.🎯 What kind of selector is h1? (a) a class selector (b) an id selector (c) an element selector
- 31.🔍 Which is the odd one out? (a) makes headings and lists (b) counts down a timer (c) reacts to a button click (d) changes the page live
- 32.💪 Which justify-content value packs boxes at the start? (a) space-between (b) center (c) flex-start (d) flex-end
-
33.⚖️ What colour is the text of this element?
<h2 class="box" id="top">Hi</h2>
CSS:
.box { color: orange; }
h2 { color: purple; }
#top { color: blue; } (a) green (b) purple (c) orange (d) blue -
34.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 270px;
justify-content: space-between;
}
Inside are 4 boxes, each 60px wide (no margins). -
35.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 460px;
justify-content: space-between;
}
Inside are 3 boxes, each 100px wide (no margins). -
36.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 18px;
}
} (a) No (b) Yes - 37.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) green (c) blue (d) white
-
38.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 8px;
}
} -
39.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 410px;
justify-content: space-between;
}
Inside are 4 boxes, each 80px wide (no margins). - 40.📱 What does a media query check? (a) the page title (b) the battery level (c) the time of day (d) the screen width
Answer key
- in the middle
- #000000
- 12
- 16
- /*
- white
- yellow
- red
- blue
- italic
- <li class="big">
- fits every screen
- HTML
- span
- yellow
- 4
- True
- border
- 128
- <span class="note">
- flex-direction
- color
- sets colours and fonts
- an element selector
- orange
- makes headings and lists
- yellow
- h1
- cyan
- an element selector
- makes headings and lists
- flex-start
- blue
- 10
- 80
- No
- blue
- 12
- 30
- the screen width
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids