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.🖌️ How big is the text, in px?
h2 {
font-size: 20px;
color: blue;
text-align: center;
background-color: green;
} -
2.✍️ What is the selector in this CSS rule?
h2 {
width: 300px;
color: red;
} (a) red (b) width (c) h1 (d) h2 - 3.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) 600px or narrower (c) turned off (d) exactly 1000px
-
4.✍️ What value is given to margin in this rule?
body {
margin: 10px;
text-align: center;
font-style: italic;
} (a) 8px (b) bold (c) margin (d) 10px - 5.What does font-weight do? (a) picks the font style (b) centres a heading (c) makes letters bigger (d) makes the text bold
-
6.✍️ What value is given to font-size in this rule?
#top {
font-size: 20px;
color: red;
} (a) center (b) font-size (c) yellow (d) 20px - 7.🌈 Which colour is #00ffff? (a) blue (b) cyan (c) yellow (d) black
- 8.🧩 Which language puts a picture on a page? (a) JavaScript (b) CSS (c) HTML
- 9.True or false: .big is an element selector. (a) False (b) True
- 10.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
- 11.🌈 Which hex code is blue? (a) #ffffff (b) #0000ff (c) #00ff00 (d) #ffff00
- 12.What does justify-content: flex-start do? (a) packs boxes at the end (b) puts boxes in the middle (c) packs boxes at the start (d) equal gaps, none at ends
- 13.🎯 Which element does the selector .red style? (a) <p class="red"> (b) <p id="red"> (c) <h1 class="star"> (d) <p class="box">
- 14.Which of these does JavaScript do? (a) rounds box corners (b) counts down a timer (c) sets colours and fonts (d) makes a form box
-
15.⚖️ What colour is the text of this element?
<h2 class="box" id="top">Hi</h2>
CSS:
h2 { color: black; }
h2 { color: yellow; } (a) black (b) white (c) red (d) yellow -
16.🎯 Which CSS selector matches this element?
<p class="box" id="hero">Hello</p> (a) .hero (b) .box (c) #top (d) h1 - 17.📱 Responsive design means a page ___. (a) is only for laptops (b) never changes (c) has no pictures (d) fits every screen
- 18.🖌️ Which CSS property makes the text bold? (a) font-size (b) font-weight (c) text-align (d) color
-
19.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 22px;
}
} -
20.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} (a) No (b) Yes -
21.✍️ How many declarations (property: value pairs) are in this rule?
.note {
padding: 8px;
border: 2px solid;
} - 22.🌈 Hex digits go 0 to 9, then A to which letter? (a) F (b) G (c) J (d) Z
-
23.✍️ What value is given to text-align in this rule?
.box {
font-weight: bold;
text-align: center;
} (a) yellow (b) center (c) text-align (d) 10px - 24.🌈 Which colour of light is strongest in rgb(70, 84, 219)? (a) green (b) blue (c) red
-
25.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 120px;
padding: 5px;
border: 1px solid black;
margin: 5px;
} - 26.✍️ How does a CSS comment start? (a) <!-- (b) // (c) # (d) /*
- 27.Which of these does JavaScript do? (a) changes the text size (b) gives the page structure (c) puts a picture on a page (d) reacts to a button click
-
28.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 60px;
padding: 20px;
border: 5px solid black;
margin: 0px;
} -
29.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 290px;
padding: 20px;
border: 4px solid black;
margin: 5px;
} - 30.✍️ In color: blue; which part is the value? (a) : (b) ; (c) color (d) blue
-
31.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 8px;
}
} (a) Yes (b) No - 32.What does color do? (a) makes letters bigger (b) centres a heading (c) colours behind the text (d) sets the letter colour
-
33.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 440px;
justify-content: center;
}
Inside are 4 boxes, each 100px wide (no margins). -
34.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 280px;
padding: 20px;
border: 4px solid black;
margin: 20px;
} -
35.🖌️ Where does the text sit on its line?
h1 {
background-color: yellow;
color: orange;
font-size: 40px;
text-align: right;
} (a) on the right (b) in the middle (c) on the left -
36.✍️ Which property is set to italic in this rule?
body {
font-size: 20px;
font-style: italic;
text-align: center;
} (a) font-size (b) color (c) italic (d) font-style -
37.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 130px;
padding: 25px;
border: 5px solid black;
margin: 15px;
} -
38.🎯 Which CSS selector matches this element?
<span class="menu" id="end">Hello</span> (a) #hero (b) .menu (c) .end (d) #menu -
39.⚖️ What colour is the text of this element?
<h1 class="menu" id="hero">Hi</h1>
CSS:
#hero { color: red; }
.menu { color: black; } (a) blue (b) white (c) black (d) red - 40.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) exactly 100px (c) 800px or wider (d) turned off
Answer key
- 20
- h2
- 600px or narrower
- 10px
- makes the text bold
- 20px
- cyan
- HTML
- False
- an id selector
- #0000ff
- packs boxes at the start
- <p class="red">
- counts down a timer
- yellow
- .box
- fits every screen
- font-weight
- 24
- No
- 2
- F
- center
- blue
- 142
- /*
- reacts to a button click
- 110
- 348
- blue
- Yes
- sets the letter colour
- 20
- 368
- on the right
- font-style
- 220
- .menu
- red
- 800px or wider
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids