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 does font-family do? (a) picks the font style (b) centres a heading (c) makes the text bold (d) makes letters bigger
- 2.What does text-align do? (a) makes letters bigger (b) colours behind the text (c) centres a heading (d) sets the letter colour
- 3.Which of these does HTML do? (a) changes the text size (b) sets colours and fonts (c) lays out the page (d) makes a link
-
4.✍️ What is the selector in this CSS rule?
#top {
color: red;
font-weight: bold;
margin: 10px;
font-size: 20px;
} (a) color (b) bold (c) #top (d) li -
5.✍️ What value is given to width in this rule?
h1 {
width: 300px;
text-align: center;
} (a) 300px (b) red (c) italic (d) width - 6.🌈 Which hex code is yellow? (a) #ffff00 (b) #000000 (c) #ff0000 (d) #00ffff
- 7.📦 In the box model, which part is space inside the border? (a) margin (b) content (c) padding (d) border
-
8.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 250px;
padding: 5px;
border: 4px solid black;
margin: 10px;
} - 9.🎯 Which element does the selector p style? (a) <h2 class="menu"> (b) <li id="intro"> (c) <p class="menu"> (d) <h1>
-
10.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 14px;
}
} - 11.True or false: JavaScript makes a form box. (a) False (b) True
- 12.✍️ CSS declarations go inside which brackets? (a) < > (b) { } (c) [ ] (d) ( )
- 13.🌈 In #380000 the red part is the hex number 38. What is it as a normal number?
-
14.✍️ How many declarations (property: value pairs) are in this rule?
#top {
color: red;
background-color: yellow;
} - 15.💪 Which flexbox property spaces boxes along a row? (a) align-items (b) flex-direction (c) justify-content (d) gap
-
16.⚖️ What colour is the text of this element?
<p class="red" id="logo">Hi</p>
CSS:
p { color: green; }
p { color: red; } (a) red (b) white (c) yellow (d) green -
17.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 50px;
padding: 5px;
border: 1px solid black;
margin: 0px;
} -
18.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 60px;
padding: 25px;
border: 4px solid black;
margin: 5px;
} -
19.✍️ Which property is set to 10px in this rule?
.note {
margin: 10px;
text-align: center;
color: red;
padding: 8px;
} (a) font-weight (b) 10px (c) padding (d) margin - 20.Which of these is padding? (a) the gap round content (b) a solid or dotted edge (c) the line round the box (d) space outside the border
- 21.🌈 Which colour is rgb(255, 255, 255)? (a) yellow (b) blue (c) white (d) black
-
22.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 1024px) {
p {
font-size: 18px;
}
} - 23.🎯 Which element does the selector p style? (a) <h1> (b) <li id="hero"> (c) <h2 class="note"> (d) <p class="note">
- 24.True or false: .note is an element selector. (a) False (b) True
-
25.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 100px;
justify-content: center;
}
Inside are 2 boxes, each 40px wide (no margins). - 26.🎨 Which tag holds CSS inside the head? (a) <script> (b) <css> (c) <body> (d) <style>
-
27.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 8px;
}
} - 28.True or false: #logo is a class selector. (a) False (b) True
- 29.🌈 Which colour is #ff0000? (a) blue (b) magenta (c) red (d) white
- 30.🌈 Which hex code is black? (a) #0000ff (b) #ff00ff (c) #000000 (d) #00ffff
- 31.True or false: the border is the line round the box. (a) False (b) True
- 32.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) red (c) blue (d) black
- 33.🌈 Which colour is rgb(255, 255, 0)? (a) red (b) yellow (c) white (d) magenta
- 34.🔍 Which is the odd one out? (a) makes headings and lists (b) gives the page structure (c) makes a link (d) lays out the page
-
35.✍️ Which property is set to 300px in this rule?
.box {
font-weight: bold;
width: 300px;
} (a) 300px (b) width (c) font-style (d) color -
36.⚖️ What colour is the text of this element?
<h1 class="menu" id="end">Hi</h1>
CSS:
#end { color: red; }
h1 { color: black; }
.menu { color: yellow; } (a) red (b) blue (c) black (d) yellow -
37.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 210px;
justify-content: flex-end;
}
Inside are 2 boxes, each 80px wide (no margins). - 38.🧩 Which language gives the page structure? (a) JavaScript (b) CSS (c) HTML
- 39.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) exactly 100px (c) 800px or wider (d) turned off
-
40.✍️ How many declarations (property: value pairs) are in this rule?
.box {
width: 300px;
padding: 8px;
border: 2px solid;
}
Answer key
- picks the font style
- centres a heading
- makes a link
- #top
- 300px
- #ffff00
- padding
- 268
- <p class="menu">
- 20
- False
- { }
- 56
- 2
- justify-content
- red
- 62
- 128
- margin
- the gap round content
- white
- 18
- <p class="note">
- False
- 10
- <style>
- 12
- False
- red
- #000000
- True
- red
- yellow
- lays out the page
- width
- red
- 50
- HTML
- 800px or wider
- 3
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids