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.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) turned off (c) 800px or wider (d) exactly 100px
-
2.✍️ What value is given to width in this rule?
h1 {
margin: 10px;
width: 300px;
} (a) width (b) red (c) 300px (d) italic - 3.📱 Responsive design means a page ___. (a) never changes (b) fits every screen (c) is only for laptops (d) has no pictures
- 4.🎯 Which element does the selector h1 style? (a) <div id="intro"> (b) <h1 class="star"> (c) <h2> (d) <li class="star">
- 5.🎨 Which tag holds CSS inside the head? (a) <css> (b) <style> (c) <script> (d) <body>
- 6.📱 What does a media query check? (a) the battery level (b) the screen width (c) the time of day (d) the page title
-
7.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 460px;
justify-content: space-between;
}
Inside are 4 boxes, each 100px wide (no margins). - 8.🔍 Which is the odd one out? (a) changes the page live (b) reacts to a button click (c) makes a form box (d) counts down a timer
- 9.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the first one (c) neither (d) the later one
-
10.✍️ What value is given to font-style in this rule?
li {
font-style: italic;
font-size: 20px;
} (a) italic (b) 20px (c) red (d) font-style -
11.🎯 Which CSS selector matches this element?
<div class="menu" id="top">Hello</div> (a) #intro (b) .menu (c) .top (d) #menu - 12.🎯 Which element does the selector p style? (a) <h1> (b) <li id="logo"> (c) <h2 class="star"> (d) <p class="star">
-
13.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 768px) {
p {
font-size: 10px;
}
} (a) Yes (b) No -
14.⚖️ What colour is the text of this element?
<p class="note" id="main">Hi</p>
CSS:
#main { color: yellow; }
.note { color: green; }
p { color: blue; } (a) red (b) yellow (c) green (d) blue -
15.🖌️ What colour are the letters?
li {
font-size: 32px;
text-align: left;
background-color: orange;
color: black;
} (a) red (b) black (c) orange - 16.📦 In the box model, which part is the gap round content? (a) content (b) border (c) margin (d) padding
-
17.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 100px;
padding: 20px;
border: 2px solid black;
margin: 0px;
} - 18.🌈 Which hex code is magenta? (a) #ff00ff (b) #00ffff (c) #ffff00 (d) #ffffff
-
19.✍️ Which property is set to 8px in this rule?
h1 {
padding: 8px;
text-align: center;
} (a) padding (b) font-weight (c) 8px (d) border - 20.✍️ CSS declarations go inside which brackets? (a) { } (b) [ ] (c) < > (d) ( )
- 21.What does font-family do? (a) centres a heading (b) makes the text bold (c) picks the font style (d) colours behind the text
-
22.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 22px;
}
} -
23.🖌️ What colour is behind the letters?
li {
text-align: left;
font-size: 24px;
background-color: orange;
color: blue;
} (a) blue (b) orange (c) white - 24.What does text-align do? (a) sets the letter colour (b) picks the font style (c) centres a heading (d) makes letters bigger
-
25.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 10px;
}
} (a) No (b) Yes - 26.🎨 Which attribute adds CSS inside one tag? (a) src (b) alt (c) style (d) href
-
27.✍️ What is the selector in this CSS rule?
li {
margin: 10px;
color: red;
font-style: italic;
font-weight: bold;
} (a) margin (b) li (c) red (d) body - 28.💪 Which flexbox property lines boxes up across? (a) display: flex (b) gap (c) flex-direction (d) align-items
- 29.🧩 Which language makes a link? (a) CSS (b) HTML (c) JavaScript
- 30.🎯 Can many elements share the same class? (a) No (b) Yes
-
31.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 190px;
justify-content: flex-end;
}
Inside are 4 boxes, each 40px wide (no margins). -
32.✍️ What is the selector in this CSS rule?
.note {
font-weight: bold;
color: red;
text-align: center;
} (a) #top (b) .note (c) font-weight (d) red -
33.✍️ Which property is set to 300px in this rule?
body {
text-align: center;
color: red;
width: 300px;
font-weight: bold;
} (a) font-style (b) 300px (c) color (d) width - 34.💪 Which justify-content value equal gaps, none at ends? (a) space-between (b) center (c) flex-end (d) flex-start
- 35.🌈 Which colour is rgb(0, 0, 0)? (a) bright green (b) white (c) cyan (d) black
- 36.True or false: .menu is a class selector. (a) True (b) False
- 37.True or false: CSS rounds box corners. (a) True (b) False
- 38.Which of these does HTML do? (a) shows a pop-up message (b) rounds box corners (c) gives the page structure (d) lays out the page
- 39.True or false: JavaScript puts a picture on a page. (a) True (b) False
- 40.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
Answer key
- 800px or wider
- 300px
- fits every screen
- <h1 class="star">
- <style>
- the screen width
- 20
- makes a form box
- the later one
- italic
- .menu
- <p class="star">
- Yes
- yellow
- black
- padding
- 144
- #ff00ff
- padding
- { }
- picks the font style
- 22
- orange
- centres a heading
- No
- style
- li
- align-items
- HTML
- Yes
- 30
- .note
- width
- space-between
- black
- True
- True
- gives the page structure
- False
- an element selector
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids