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.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the later one (c) the first one (d) neither
- 2.🌈 Which hex code is magenta? (a) #0000ff (b) #00ffff (c) #ffff00 (d) #ff00ff
-
3.✍️ Which property is set to italic in this rule?
.note {
text-align: center;
font-style: italic;
} (a) font-size (b) italic (c) color (d) font-style - 4.✍️ CSS declarations go inside which brackets? (a) [ ] (b) ( ) (c) { } (d) < >
-
5.🖌️ What colour is behind the letters?
p {
text-align: left;
font-size: 12px;
color: blue;
background-color: orange;
} (a) orange (b) blue (c) yellow - 6.True or false: li is an id selector. (a) False (b) True
-
7.🖌️ What colour is behind the letters?
p {
text-align: center;
background-color: orange;
color: blue;
font-size: 20px;
} (a) orange (b) green (c) blue - 8.🧩 Which language makes a link? (a) JavaScript (b) CSS (c) HTML
-
9.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 18px;
}
} - 10.🌈 Which hex code is white? (a) #00ff00 (b) #ffff00 (c) #000000 (d) #ffffff
- 11.🌈 In #0000f2 the blue part is the hex number f2. What is it as a normal number?
-
12.🎯 Which CSS selector matches this element?
<p class="box" id="end">Hello</p> (a) .star (b) #box (c) .box (d) h1 - 13.Which of these does JavaScript do? (a) puts a picture on a page (b) adds space around boxes (c) gives the page structure (d) reacts to a button click
- 14.🎯 Which sign starts a class selector? (a) & (b) @ (c) . (d) #
- 15.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
-
16.🎯 Which CSS selector matches this element?
<span class="box" id="end">Hello</span> (a) .box (b) p (c) #box (d) #hero -
17.✍️ What value is given to color in this rule?
.note {
border: 2px solid;
margin: 10px;
color: red;
} (a) color (b) red (c) 20px (d) center - 18.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) exactly 100px (c) 800px or wider (d) 800px or narrower
- 19.True or false: #top is an id selector. (a) True (b) False
- 20.🎯 What kind of selector is .card? (a) a class selector (b) an element selector (c) an id selector
- 21.📦 In the box model, which part is space inside the border? (a) margin (b) padding (c) border (d) content
- 22.🌈 Hex digits go 0 to 9, then A to which letter? (a) Z (b) F (c) G (d) J
- 23.🎯 What kind of selector is h1? (a) an id selector (b) an element selector (c) a class selector
- 24.Which of these does HTML do? (a) adds space around boxes (b) gives the page structure (c) reacts to a button click (d) lays out the page
- 25.📱 Which tag helps phones show a page at the right size? (a) the br tag (b) the viewport meta tag (c) the hr tag (d) the title tag
-
26.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 600px) {
p {
font-size: 20px;
}
} (a) No (b) Yes - 27.🌈 Which colour of light is strongest in rgb(95, 7, 155)? (a) blue (b) green (c) red
-
28.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 200px;
padding: 30px;
border: 4px solid black;
margin: 15px;
} -
29.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 18px;
}
} (a) Yes (b) No -
30.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 200px;
padding: 20px;
border: 3px solid black;
margin: 15px;
} - 31.🎨 One CSS file can style how many pages? (a) only one image (b) no pages (c) many pages (d) only one word
-
32.🖌️ What colour is behind the letters?
h1 {
color: red;
background-color: purple;
text-align: center;
font-size: 40px;
} (a) purple (b) red (c) orange -
33.🖌️ How big is the text, in px?
li {
background-color: yellow;
color: black;
text-align: left;
font-size: 40px;
} - 34.🎯 How many elements on a page should have the same id? (a) any number (b) 1 (c) 5 (d) 2
-
35.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 180px;
justify-content: center;
}
Inside are 2 boxes, each 50px wide (no margins). -
36.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 14px;
}
} (a) Yes (b) No -
37.⚖️ What colour is the text of this element?
<p class="note" id="logo">Hi</p>
CSS:
.note { color: orange; }
.note { color: green; } (a) red (b) white (c) green (d) orange -
38.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 270px;
justify-content: center;
}
Inside are 3 boxes, each 50px wide (no margins). -
39.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 240px;
justify-content: flex-start;
}
Inside are 4 boxes, each 40px wide (no margins). -
40.✍️ How many declarations (property: value pairs) are in this rule?
.box {
padding: 8px;
color: red;
border: 2px solid;
}
Answer key
- the later one
- #ff00ff
- font-style
- { }
- orange
- False
- orange
- HTML
- 18
- #ffffff
- 242
- .box
- reacts to a button click
- .
- an element selector
- .box
- red
- 800px or wider
- True
- a class selector
- padding
- F
- an element selector
- gives the page structure
- the viewport meta tag
- No
- blue
- 298
- No
- 246
- many pages
- purple
- 40
- 1
- 40
- No
- green
- 60
- 80
- 3
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids