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.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) red (c) white (d) blue
-
2.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 50px;
padding: 30px;
border: 3px solid black;
margin: 10px;
} - 3.💪 Which justify-content value equal gaps, none at ends? (a) flex-start (b) flex-end (c) center (d) space-between
-
4.🖌️ What colour is behind the letters?
li {
color: yellow;
text-align: right;
font-size: 12px;
background-color: white;
} (a) orange (b) white (c) yellow - 5.✍️ Which sign goes between a property and its value? (a) = (b) - (c) : (d) ;
- 6.🔍 Which is the odd one out? (a) adds space around boxes (b) changes the text size (c) makes a link (d) rounds box corners
-
7.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 170px;
padding: 15px;
border: 5px solid black;
margin: 20px;
} - 8.🌈 Which colour is #ff0000? (a) bright green (b) blue (c) cyan (d) red
- 9.🌈 Which hex code is cyan? (a) #00ffff (b) #0000ff (c) #ff0000 (d) #ffff00
- 10.🧩 Which language checks a quiz answer? (a) CSS (b) JavaScript (c) HTML
- 11.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) turned off (c) exactly 1000px (d) 600px or narrower
- 12.🎯 Which element does the selector div style? (a) <span> (b) <div class="star"> (c) <p class="star"> (d) <h1 id="intro">
- 13.✍️ CSS declarations go inside which brackets? (a) ( ) (b) { } (c) < > (d) [ ]
- 14.Which of these is padding? (a) the text or picture (b) a solid or dotted edge (c) the gap to other boxes (d) space inside the border
-
15.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 440px;
justify-content: center;
}
Inside are 3 boxes, each 100px wide (no margins). -
16.⚖️ What colour is the text of this element?
<p class="menu" id="hero">Hi</p>
CSS:
p { color: red; }
p { color: blue; } (a) red (b) blue (c) white (d) green - 17.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
-
18.✍️ What is the selector in this CSS rule?
h1 {
font-style: italic;
text-align: center;
font-weight: bold;
} (a) p (b) font-style (c) h1 (d) center -
19.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 26px;
}
} - 20.💪 Which flexbox property turns on flexbox? (a) align-items (b) display: flex (c) justify-content (d) flex-direction
- 21.True or false: padding is space inside the border. (a) False (b) True
-
22.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 768px) {
p {
font-size: 14px;
}
} (a) Yes (b) No - 23.🌈 Which colour is #ff00ff? (a) black (b) yellow (c) magenta (d) blue
- 24.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the shorter one (c) the first one (d) the later one
- 25.🌈 Which colour is #000000? (a) magenta (b) yellow (c) black (d) red
- 26.🧩 Which language reacts to a button click? (a) JavaScript (b) CSS (c) HTML
-
27.🖌️ What colour is behind the letters?
li {
font-size: 40px;
color: orange;
text-align: center;
background-color: blue;
} (a) black (b) blue (c) orange - 28.💪 Which flexbox property sets space between boxes? (a) gap (b) flex-direction (c) justify-content (d) align-items
-
29.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 180px;
padding: 5px;
border: 2px solid black;
margin: 10px;
} - 30.💪 Which flexbox property lines boxes up across? (a) display: flex (b) justify-content (c) gap (d) align-items
- 31.True or false: .star is a class selector. (a) True (b) False
-
32.🖌️ What colour are the letters?
h1 {
font-size: 12px;
color: orange;
text-align: left;
background-color: black;
} (a) orange (b) red (c) black - 33.🌈 Which colour is #ffffff? (a) black (b) red (c) bright green (d) white
- 34.What does color do? (a) centres a heading (b) sets the letter colour (c) makes the text bold (d) colours behind the text
-
35.✍️ What is the selector in this CSS rule?
p {
background-color: yellow;
font-weight: bold;
font-style: italic;
} (a) bold (b) p (c) background-color (d) .note - 36.🎯 Can many elements share the same class? (a) Yes (b) No
- 37.🌈 In #00002e the blue part is the hex number 2e. What is it as a normal number?
- 38.🎯 Which element does the selector p style? (a) <h2 class="menu"> (b) <p class="menu"> (c) <li id="logo"> (d) <h1>
- 39.True or false: the border is the gap round content. (a) True (b) False
-
40.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 16px;
}
}
Answer key
- blue
- 136
- space-between
- white
- :
- makes a link
- 250
- red
- #00ffff
- JavaScript
- 600px or narrower
- <div class="star">
- { }
- space inside the border
- 70
- blue
- an element selector
- h1
- 24
- display: flex
- True
- No
- magenta
- the later one
- black
- JavaScript
- blue
- gap
- 214
- align-items
- True
- orange
- white
- sets the letter colour
- p
- Yes
- 46
- <p class="menu">
- False
- 16
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids