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.🎯 Which CSS selector matches this element?
<h1 class="note" id="intro">Hello</h1> (a) .big (b) .intro (c) #note (d) .note - 2.✍️ Which sign ends each CSS declaration? (a) . (b) , (c) ; (d) :
-
3.✍️ What is the selector in this CSS rule?
p {
background-color: yellow;
color: red;
font-size: 20px;
} (a) red (b) background-color (c) p (d) .note -
4.🖌️ What colour are the letters?
li {
color: orange;
text-align: left;
background-color: white;
font-size: 24px;
} (a) orange (b) white (c) red -
5.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 240px;
justify-content: flex-start;
}
Inside are 2 boxes, each 80px wide (no margins). - 6.🔍 Which is the odd one out? (a) sets colours and fonts (b) gives the page structure (c) makes a link (d) makes headings and lists
- 7.📦 In the box model, which part is space inside the border? (a) padding (b) margin (c) content (d) border
- 8.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
- 9.🎯 Which element does the selector div style? (a) <h1 id="main"> (b) <p class="star"> (c) <div class="star"> (d) <span>
-
10.✍️ Which property is set to 10px in this rule?
#top {
font-weight: bold;
margin: 10px;
} (a) font-weight (b) padding (c) margin (d) 10px - 11.🌈 In #rrggbb, which colour do the last two digits give? (a) red (b) green (c) blue (d) white
- 12.What does text-align do? (a) makes the text bold (b) makes letters bigger (c) centres a heading (d) sets the letter colour
- 13.📱 Responsive design means a page ___. (a) has no pictures (b) is only for laptops (c) never changes (d) fits every screen
- 14.🎨 Which tag holds CSS inside the head? (a) <style> (b) <script> (c) <body> (d) <css>
-
15.🖌️ How big is the text, in px?
li {
font-size: 16px;
color: blue;
text-align: right;
background-color: yellow;
} - 16.🧩 Which language makes a form box? (a) HTML (b) CSS (c) JavaScript
- 17.Which of these is the border? (a) the gap to other boxes (b) space outside the border (c) the line round the box (d) the text or picture
-
18.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
padding: 8px;
font-style: italic;
} - 19.🌈 Which colour is #ff0000? (a) red (b) blue (c) yellow (d) bright green
- 20.🌈 Which hex code is cyan? (a) #00ffff (b) #ff0000 (c) #ffffff (d) #000000
-
21.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} - 22.🖌️ Which CSS property picks the font style? (a) background-color (b) font-family (c) text-align (d) color
-
23.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 180px;
padding: 10px;
border: 5px solid black;
margin: 20px;
} - 24.✍️ CSS declarations go inside which brackets? (a) ( ) (b) { } (c) < > (d) [ ]
- 25.🌈 What is the biggest number one colour can have in rgb()? (a) 100 (b) 255 (c) 99 (d) 1000
- 26.📱 max-width: 600px applies when the screen is ___. (a) 600px or narrower (b) exactly 1000px (c) turned off (d) 600px or wider
- 27.What does justify-content: flex-end do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the end (d) packs boxes at the start
-
28.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 140px;
justify-content: space-between;
}
Inside are 2 boxes, each 60px wide (no margins). -
29.🖌️ Where does the text sit on its line?
li {
background-color: blue;
font-size: 40px;
color: purple;
text-align: right;
} (a) in the middle (b) on the right (c) on the left - 30.💪 Which flexbox property sets space between boxes? (a) justify-content (b) display: flex (c) gap (d) flex-direction
- 31.💪 Which flexbox property turns on flexbox? (a) gap (b) display: flex (c) flex-direction (d) align-items
-
32.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 2 boxes, each 60px wide (no margins). -
33.📦 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: 5px;
border: 5px solid black;
margin: 10px;
} - 34.Which of these does CSS do? (a) changes the text size (b) makes headings and lists (c) reacts to a button click (d) makes a link
-
35.⚖️ What colour is the text of this element?
<h1 class="box" id="end">Hi</h1>
CSS:
h1 { color: purple; }
h1 { color: blue; } (a) blue (b) purple (c) red (d) white - 36.Which of these does CSS do? (a) changes the page live (b) counts down a timer (c) shows a pop-up message (d) rounds box corners
-
37.🖌️ What colour is behind the letters?
p {
background-color: black;
text-align: right;
font-size: 32px;
color: purple;
} (a) purple (b) yellow (c) black -
38.🖌️ How big is the text, in px?
h2 {
text-align: center;
font-size: 12px;
color: purple;
background-color: blue;
} -
39.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
font-weight: bold;
padding: 8px;
font-style: italic;
} -
40.⚖️ What colour is the text of this element?
<h2 class="star" id="intro">Hi</h2>
CSS:
h2 { color: green; }
#intro { color: blue; } (a) red (b) blue (c) yellow (d) green
Answer key
- .note
- ;
- p
- orange
- 80
- sets colours and fonts
- padding
- an element selector
- <div class="star">
- margin
- blue
- centres a heading
- fits every screen
- <style>
- 16
- HTML
- the line round the box
- 2
- red
- #00ffff
- 10
- font-family
- 250
- { }
- 255
- 600px or narrower
- packs boxes at the end
- 20
- on the right
- gap
- display: flex
- 70
- 220
- changes the text size
- blue
- rounds box corners
- black
- 12
- 3
- blue
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids