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 kind of selector is #main? (a) an id selector (b) a class selector (c) an element selector
- 2.True or false: .big is an element selector. (a) False (b) True
-
3.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 480px) {
p {
font-size: 10px;
}
} - 4.🌈 Which hex code is blue? (a) #ff0000 (b) #ffffff (c) #ff00ff (d) #0000ff
- 5.💪 Which flexbox property picks row or column? (a) display: flex (b) flex-direction (c) gap (d) align-items
-
6.✍️ What value is given to padding in this rule?
.note {
font-size: 20px;
width: 300px;
border: 2px solid;
padding: 8px;
} (a) 8px (b) padding (c) bold (d) 2px solid -
7.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
width: 300px;
} - 8.What does font-size do? (a) makes the text bold (b) makes letters bigger (c) sets the letter colour (d) picks the font style
- 9.📦 In the box model, which part is a solid or dotted edge? (a) padding (b) content (c) border (d) margin
- 10.🎯 What kind of selector is .big? (a) an id selector (b) a class selector (c) an element selector
- 11.True or false: the border is the line round the box. (a) False (b) True
-
12.✍️ Which property is set to 10px in this rule?
body {
color: red;
margin: 10px;
width: 300px;
background-color: yellow;
} (a) padding (b) 10px (c) font-weight (d) margin - 13.True or false: padding is space inside the border. (a) False (b) True
- 14.🧩 Which language puts a picture on a page? (a) HTML (b) CSS (c) JavaScript
- 15.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) turned off (c) exactly 100px (d) 800px or wider
-
16.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 170px;
justify-content: space-between;
}
Inside are 2 boxes, each 60px wide (no margins). - 17.🌈 Which hex code is black? (a) #ffffff (b) #ffff00 (c) #000000 (d) #00ff00
- 18.Which of these does HTML do? (a) lays out the page (b) gives the page structure (c) sets colours and fonts (d) reacts to a button click
-
19.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 190px;
padding: 20px;
border: 3px solid black;
margin: 10px;
} -
20.💪 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). - 21.💪 Which justify-content value packs boxes at the start? (a) flex-end (b) space-between (c) center (d) flex-start
-
22.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 150px;
padding: 30px;
border: 5px solid black;
margin: 10px;
} - 23.🌈 Which colour is #ffff00? (a) white (b) yellow (c) black (d) bright green
- 24.🌈 In #00c500 the green part is the hex number c5. What is it as a normal number?
-
25.🖌️ What colour is behind the letters?
h1 {
text-align: left;
color: orange;
background-color: yellow;
font-size: 28px;
} (a) purple (b) orange (c) yellow - 26.🎨 A CSS file usually ends with which extension? (a) .css (b) .js (c) .png (d) .html
-
27.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
margin: 10px;
width: 300px;
font-style: italic;
} - 28.🎨 Which tag holds CSS inside the head? (a) <body> (b) <style> (c) <css> (d) <script>
-
29.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 16px;
}
} - 30.📦 In the box model, which part is space outside the border? (a) margin (b) border (c) padding (d) content
- 31.🌈 Which colour is rgb(255, 0, 255)? (a) red (b) bright green (c) yellow (d) magenta
-
32.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 90px;
padding: 5px;
border: 2px solid black;
margin: 5px;
} - 33.🎯 How many elements on a page should have the same id? (a) 5 (b) 1 (c) 2 (d) any number
-
34.🎯 Which CSS selector matches this element?
<span class="star" id="hero">Hello</span> (a) #star (b) #hero (c) #top (d) .hero -
35.⚖️ What colour is the text of this element?
<p class="menu" id="hero">Hi</p>
CSS:
p { color: orange; }
#hero { color: yellow; } (a) orange (b) blue (c) purple (d) yellow - 36.🔍 Which is the odd one out? (a) adds space around boxes (b) checks a quiz answer (c) changes the text size (d) sets colours and fonts
-
37.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 160px;
padding: 25px;
border: 3px solid black;
margin: 0px;
} - 38.🖌️ Which CSS property makes letters bigger? (a) font-weight (b) font-family (c) font-size (d) background-color
- 39.True or false: the border is a solid or dotted edge. (a) False (b) True
- 40.True or false: .big is a class selector. (a) False (b) True
Answer key
- an id selector
- False
- 10
- #0000ff
- flex-direction
- 8px
- 1
- makes letters bigger
- border
- a class selector
- True
- margin
- True
- HTML
- 800px or wider
- 50
- #000000
- gives the page structure
- 256
- 10
- flex-start
- 240
- yellow
- 197
- yellow
- .css
- 3
- <style>
- 16
- margin
- magenta
- 114
- 1
- #hero
- yellow
- checks a quiz answer
- 216
- font-size
- True
- True
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids