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 colour is #ffffff? (a) magenta (b) bright green (c) black (d) white
-
2.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 18px;
}
} (a) No (b) Yes - 3.✍️ Which sign goes between a property and its value? (a) ; (b) = (c) : (d) -
- 4.💪 Which flexbox property picks row or column? (a) justify-content (b) flex-direction (c) display: flex (d) gap
-
5.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 240px;
justify-content: center;
}
Inside are 2 boxes, each 50px wide (no margins). - 6.🧩 Which language gives the page structure? (a) JavaScript (b) HTML (c) CSS
- 7.True or false: JavaScript lays out the page. (a) False (b) True
-
8.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 110px;
padding: 5px;
border: 1px solid black;
margin: 0px;
} -
9.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 210px;
justify-content: flex-start;
}
Inside are 4 boxes, each 50px wide (no margins). -
10.🖌️ What colour are the letters?
li {
color: white;
font-size: 20px;
background-color: yellow;
text-align: center;
} (a) white (b) yellow (c) green - 11.🧩 Which language checks a quiz answer? (a) CSS (b) JavaScript (c) HTML
- 12.🎯 Which element does the selector #end style? (a) <div class="menu"> (b) <li id="hero"> (c) <li class="end"> (d) <li id="end">
- 13.🎯 Can many elements share the same class? (a) No (b) Yes
- 14.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
- 15.✍️ Which sign ends each CSS declaration? (a) : (b) . (c) ; (d) ,
- 16.Which of these is padding? (a) the text or picture (b) space outside the border (c) space inside the border (d) the gap to other boxes
-
17.⚖️ What colour is the text of this element?
<p class="box" id="hero">Hi</p>
CSS:
p { color: white; }
#hero { color: red; }
.box { color: orange; } (a) white (b) orange (c) red (d) black - 18.🔍 Which is the odd one out? (a) gives the page structure (b) sets colours and fonts (c) makes a form box (d) puts a picture on a page
- 19.📱 What does a media query check? (a) the screen width (b) the battery level (c) the time of day (d) the page title
-
20.⚖️ What colour is the text of this element?
<h2 class="menu" id="intro">Hi</h2>
CSS:
h2 { color: black; }
h2 { color: red; } (a) blue (b) red (c) orange (d) black -
21.⚖️ What colour is the text of this element?
<p class="star" id="intro">Hi</p>
CSS:
.star { color: yellow; }
#intro { color: blue; }
p { color: green; } (a) orange (b) green (c) blue (d) yellow - 22.🔍 Which is the odd one out? (a) counts down a timer (b) shows a pop-up message (c) rounds box corners (d) reacts to a button click
- 23.What does color do? (a) colours behind the text (b) centres a heading (c) sets the letter colour (d) makes the text bold
- 24.🎨 Which tag connects an outside CSS file? (a) <img> (b) <a> (c) <link> (d) <css>
-
25.🖌️ What colour are the letters?
h1 {
text-align: left;
color: blue;
font-size: 20px;
background-color: orange;
} (a) green (b) orange (c) blue - 26.🌈 Which colour of light is strongest in rgb(41, 116, 217)? (a) green (b) blue (c) red
- 27.🎯 Which element does the selector .red style? (a) <h2 class="star"> (b) <h1 class="red"> (c) <h1 id="red"> (d) <h1 class="box">
- 28.What does justify-content: center do? (a) packs boxes at the end (b) packs boxes at the start (c) equal gaps, none at ends (d) puts boxes in the middle
- 29.🌈 What is the biggest number one colour can have in rgb()? (a) 99 (b) 255 (c) 1000 (d) 100
- 30.🎨 One CSS file can style how many pages? (a) only one image (b) many pages (c) only one word (d) no pages
- 31.📦 In the box model, which part is the line round the box? (a) margin (b) padding (c) content (d) border
- 32.🎯 What kind of selector is #hero? (a) a class selector (b) an id selector (c) an element selector
- 33.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) exactly 100px (c) 800px or narrower (d) 800px or wider
- 34.📦 In the box model, which part is space inside the border? (a) content (b) border (c) padding (d) margin
- 35.What does text-align do? (a) centres a heading (b) picks the font style (c) makes the text bold (d) makes letters bigger
- 36.📦 In the box model, which part is space outside the border? (a) content (b) margin (c) border (d) padding
-
37.✍️ What value is given to padding in this rule?
h2 {
padding: 8px;
width: 300px;
} (a) 8px (b) bold (c) padding (d) 2px solid -
38.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 1024px) {
p {
font-size: 30px;
}
} (a) Yes (b) No - 39.🖌️ Which CSS property makes letters bigger? (a) background-color (b) font-size (c) font-family (d) color
-
40.🖌️ Where does the text sit on its line?
h2 {
font-size: 12px;
background-color: blue;
text-align: right;
color: orange;
} (a) on the left (b) in the middle (c) on the right
Answer key
- white
- No
- :
- flex-direction
- 70
- HTML
- False
- 122
- 10
- white
- JavaScript
- <li id="end">
- Yes
- an element selector
- ;
- space inside the border
- red
- sets colours and fonts
- the screen width
- red
- blue
- rounds box corners
- sets the letter colour
- <link>
- blue
- blue
- <h1 class="red">
- puts boxes in the middle
- 255
- many pages
- border
- an id selector
- 800px or wider
- padding
- centres a heading
- margin
- 8px
- No
- font-size
- on the right
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids