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.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 600px) {
p {
font-size: 18px;
}
} (a) Yes (b) No - 2.🔍 Which is the odd one out? (a) counts down a timer (b) checks a quiz answer (c) shows a pop-up message (d) rounds box corners
- 3.✍️ Which sign ends each CSS declaration? (a) ; (b) . (c) : (d) ,
- 4.✍️ Which sign goes between a property and its value? (a) : (b) = (c) - (d) ;
-
5.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 240px;
justify-content: center;
}
Inside are 2 boxes, each 80px wide (no margins). -
6.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} -
7.✍️ How many declarations (property: value pairs) are in this rule?
body {
margin: 10px;
font-size: 20px;
} -
8.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 18px;
}
} - 9.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
- 10.Which of these is the content? (a) the line round the box (b) the text or picture (c) a solid or dotted edge (d) space outside the border
- 11.True or false: CSS adds space around boxes. (a) True (b) False
- 12.🌈 Which hex code is yellow? (a) #00ffff (b) #0000ff (c) #ff0000 (d) #ffff00
-
13.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 14px;
}
} (a) Yes (b) No -
14.✍️ What is the selector in this CSS rule?
p {
border: 2px solid;
background-color: yellow;
font-size: 20px;
font-weight: bold;
} (a) .note (b) yellow (c) border (d) p -
15.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 140px;
padding: 5px;
border: 2px solid black;
margin: 10px;
} -
16.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 60px;
padding: 15px;
border: 3px solid black;
margin: 0px;
} - 17.✍️ How does a CSS comment start? (a) <!-- (b) # (c) /* (d) //
- 18.Which of these is the border? (a) space inside the border (b) a solid or dotted edge (c) the text or picture (d) the gap round content
- 19.🧩 Which language rounds box corners? (a) CSS (b) JavaScript (c) HTML
- 20.🧩 Which language counts down a timer? (a) HTML (b) JavaScript (c) CSS
- 21.True or false: padding is the gap round content. (a) False (b) True
-
22.✍️ How many declarations (property: value pairs) are in this rule?
li {
width: 300px;
font-weight: bold;
background-color: yellow;
font-size: 20px;
} - 23.Which of these is margin? (a) a solid or dotted edge (b) the gap round content (c) the text or picture (d) the gap to other boxes
- 24.✍️ In color: blue; which part is the value? (a) color (b) ; (c) : (d) blue
-
25.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
font-style: italic;
margin: 10px;
width: 300px;
} - 26.📱 Which tag helps phones show a page at the right size? (a) the viewport meta tag (b) the title tag (c) the br tag (d) the hr tag
-
27.✍️ Which property is set to bold in this rule?
#top {
color: red;
font-weight: bold;
text-align: center;
} (a) border (b) font-weight (c) width (d) bold -
28.🎯 Which CSS selector matches this element?
<p class="menu" id="hero">Hello</p> (a) #menu (b) #hero (c) .note (d) h1 -
29.✍️ How many declarations (property: value pairs) are in this rule?
.note {
margin: 10px;
} - 30.🌈 Which colour of light is strongest in rgb(126, 60, 220)? (a) red (b) blue (c) green
-
31.🖌️ What colour is behind the letters?
li {
color: white;
text-align: center;
font-size: 12px;
background-color: black;
} (a) white (b) yellow (c) black -
32.⚖️ What colour is the text of this element?
<h2 class="big" id="top">Hi</h2>
CSS:
#top { color: black; }
h2 { color: yellow; }
.big { color: red; } (a) red (b) black (c) yellow (d) white -
33.🖌️ Where does the text sit on its line?
h2 {
color: blue;
font-size: 20px;
text-align: right;
background-color: red;
} (a) on the left (b) on the right (c) in the middle - 34.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the first one (c) neither (d) the shorter one
- 35.What does text-align do? (a) sets the letter colour (b) makes the text bold (c) centres a heading (d) picks the font style
- 36.🌈 Which colour is rgb(255, 0, 0)? (a) yellow (b) white (c) red (d) black
- 37.🖌️ Which CSS property centres a heading? (a) background-color (b) font-family (c) font-size (d) text-align
-
38.⚖️ What colour is the text of this element?
<h1 class="red" id="main">Hi</h1>
CSS:
h1 { color: red; }
.red { color: white; } (a) white (b) orange (c) red (d) black - 39.📦 In the box model, which part is space outside the border? (a) padding (b) border (c) margin (d) content
-
40.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 6px;
}
}
Answer key
- No
- rounds box corners
- ;
- :
- 40
- 10
- 2
- 18
- an id selector
- the text or picture
- True
- #ffff00
- Yes
- p
- 174
- 96
- /*
- a solid or dotted edge
- CSS
- JavaScript
- True
- 4
- the gap to other boxes
- blue
- 3
- the viewport meta tag
- font-weight
- #hero
- 1
- blue
- black
- black
- on the right
- the later one
- centres a heading
- red
- text-align
- white
- margin
- 6
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids