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 value is given to border in this rule?
#top {
font-weight: bold;
padding: 8px;
border: 2px solid;
} (a) border (b) 300px (c) italic (d) 2px solid - 2.🎯 Can many elements share the same class? (a) Yes (b) No
- 3.Which of these is padding? (a) a solid or dotted edge (b) the gap to other boxes (c) the line round the box (d) the gap round content
- 4.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the later one (c) the shorter one (d) neither
- 5.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or wider (c) 600px or narrower (d) turned off
-
6.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 300px;
padding: 10px;
border: 4px solid black;
margin: 0px;
} - 7.🎨 One CSS file can style how many pages? (a) only one image (b) no pages (c) only one word (d) many pages
- 8.📦 In the box model, which part is the gap to other boxes? (a) padding (b) content (c) border (d) margin
-
9.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 170px;
padding: 10px;
border: 3px solid black;
margin: 5px;
} - 10.🌈 In #000041 the blue part is the hex number 41. What is it as a normal number?
- 11.🌈 Which hex code is magenta? (a) #000000 (b) #ffff00 (c) #ff00ff (d) #00ffff
- 12.Which of these does HTML do? (a) adds space around boxes (b) changes the text size (c) shows a pop-up message (d) makes headings and lists
- 13.🌈 Which colour is rgb(255, 255, 255)? (a) blue (b) black (c) yellow (d) white
-
14.⚖️ What colour is the text of this element?
<h1 class="big" id="top">Hi</h1>
CSS:
.big { color: red; }
#top { color: blue; }
h1 { color: green; } (a) blue (b) yellow (c) green (d) red - 15.✍️ How does a CSS comment start? (a) /* (b) // (c) # (d) <!--
-
16.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 10px;
}
} - 17.🔍 Which is the odd one out? (a) rounds box corners (b) adds space around boxes (c) sets colours and fonts (d) makes headings and lists
- 18.What does font-size do? (a) makes the text bold (b) makes letters bigger (c) colours behind the text (d) picks the font style
- 19.🧩 Which language counts down a timer? (a) HTML (b) JavaScript (c) CSS
-
20.🎯 Which CSS selector matches this element?
<h2 class="red" id="top">Hello</h2> (a) #top (b) .top (c) #intro (d) .box - 21.True or false: HTML puts a picture on a page. (a) True (b) False
-
22.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 160px;
padding: 20px;
border: 1px solid black;
margin: 10px;
} - 23.🎨 A CSS file usually ends with which extension? (a) .js (b) .png (c) .css (d) .html
-
24.✍️ Which property is set to 8px in this rule?
#top {
padding: 8px;
background-color: yellow;
font-size: 20px;
text-align: center;
} (a) 8px (b) padding (c) border (d) font-weight - 25.🌈 Which colour is rgb(0, 0, 0)? (a) black (b) cyan (c) bright green (d) yellow
- 26.✍️ In color: blue; which part is the property? (a) blue (b) : (c) color (d) ;
-
27.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 400px;
justify-content: center;
}
Inside are 4 boxes, each 80px wide (no margins). -
28.🎯 Which CSS selector matches this element?
<li class="star" id="top">Hello</li> (a) .menu (b) #intro (c) .star (d) .top -
29.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 200px;
padding: 10px;
border: 2px solid black;
margin: 5px;
} - 30.📱 min-width: 800px applies when the screen is ___. (a) exactly 100px (b) 800px or narrower (c) 800px or wider (d) turned off
- 31.True or false: p is an element selector. (a) True (b) False
- 32.💪 Which flexbox property spaces boxes along a row? (a) gap (b) align-items (c) display: flex (d) justify-content
- 33.Which of these does JavaScript do? (a) makes headings and lists (b) makes a form box (c) puts a picture on a page (d) reacts to a button click
-
34.⚖️ What colour is the text of this element?
<h1 class="big" id="logo">Hi</h1>
CSS:
#logo { color: green; }
#logo { color: black; } (a) orange (b) purple (c) black (d) green - 35.📦 In the box model, which part is a solid or dotted edge? (a) padding (b) border (c) margin (d) content
- 36.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 3 (b) 2 (c) 4 (d) 6
- 37.What does background-color do? (a) makes letters bigger (b) makes the text bold (c) sets the letter colour (d) colours behind the text
- 38.🎯 What kind of selector is .note? (a) an id selector (b) a class selector (c) an element selector
- 39.📦 In the box model, which part is space inside the border? (a) padding (b) margin (c) border (d) content
- 40.📱 Responsive design means a page ___. (a) is only for laptops (b) fits every screen (c) has no pictures (d) never changes
Answer key
- 2px solid
- Yes
- the gap round content
- the later one
- 600px or narrower
- 328
- many pages
- margin
- 206
- 65
- #ff00ff
- makes headings and lists
- white
- blue
- /*
- 10
- makes headings and lists
- makes letters bigger
- JavaScript
- #top
- True
- 222
- .css
- padding
- black
- color
- 40
- .star
- 234
- 800px or wider
- True
- justify-content
- reacts to a button click
- black
- border
- 3
- colours behind the text
- a class selector
- padding
- fits every screen
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids