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.True or false: padding is the line round the box. (a) True (b) False
-
2.🎯 Which CSS selector matches this element?
<h1 class="box" id="intro">Hello</h1> (a) .intro (b) h2 (c) .star (d) h1 - 3.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
- 4.🎨 Which tag holds CSS inside the head? (a) <css> (b) <style> (c) <script> (d) <body>
- 5.🌈 Which hex code is yellow? (a) #ffff00 (b) #ff0000 (c) #00ff00 (d) #000000
-
6.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 20px;
}
} (a) Yes (b) No - 7.🎯 Which sign starts an id selector? (a) . (b) # (c) & (d) @
- 8.True or false: margin is the gap to other boxes. (a) False (b) True
-
9.⚖️ What colour is the text of this element?
<h1 class="star" id="hero">Hi</h1>
CSS:
#hero { color: black; }
.star { color: blue; }
h1 { color: green; } (a) black (b) blue (c) orange (d) green -
10.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 60px;
padding: 20px;
border: 2px solid black;
margin: 10px;
} - 11.Which of these does CSS do? (a) reacts to a button click (b) makes a form box (c) rounds box corners (d) makes headings and lists
- 12.True or false: margin is a solid or dotted edge. (a) False (b) True
-
13.🖌️ What colour are the letters?
p {
color: orange;
background-color: purple;
text-align: right;
font-size: 24px;
} (a) purple (b) red (c) orange - 14.True or false: padding is the gap round content. (a) False (b) True
-
15.🖌️ What colour are the letters?
li {
text-align: center;
background-color: black;
color: white;
font-size: 16px;
} (a) red (b) black (c) white - 16.🔍 Which is the odd one out? (a) makes headings and lists (b) gives the page structure (c) makes a form box (d) sets colours and fonts
- 17.✍️ CSS declarations go inside which brackets? (a) < > (b) { } (c) ( ) (d) [ ]
- 18.Which of these does JavaScript do? (a) makes headings and lists (b) changes the text size (c) checks a quiz answer (d) lays out the page
-
19.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 140px;
padding: 15px;
border: 1px solid black;
margin: 20px;
} - 20.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
-
21.⚖️ What colour is the text of this element?
<p class="star" id="top">Hi</p>
CSS:
.star { color: orange; }
p { color: blue; } (a) orange (b) blue (c) green (d) white - 22.True or false: JavaScript adds space around boxes. (a) False (b) True
- 23.🎯 Which sign starts a class selector? (a) @ (b) & (c) # (d) .
- 24.🌈 Which colour of light is strongest in rgb(162, 71, 53)? (a) red (b) green (c) blue
-
25.🎯 Which CSS selector matches this element?
<h1 class="note" id="end">Hello</h1> (a) h2 (b) #note (c) .big (d) h1 - 26.Which of these does CSS do? (a) makes headings and lists (b) makes a link (c) changes the page live (d) adds space around boxes
-
27.✍️ What value is given to border in this rule?
li {
text-align: center;
border: 2px solid;
} (a) 2px solid (b) border (c) italic (d) 300px - 28.🧩 Which language checks a quiz answer? (a) CSS (b) JavaScript (c) HTML
-
29.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 240px;
justify-content: center;
}
Inside are 3 boxes, each 60px wide (no margins). -
30.⚖️ What colour is the text of this element?
<p class="star" id="top">Hi</p>
CSS:
p { color: blue; }
p { color: purple; } (a) yellow (b) blue (c) green (d) purple - 31.📱 max-width: 600px applies when the screen is ___. (a) 600px or narrower (b) exactly 1000px (c) turned off (d) 600px or wider
-
32.✍️ Which property is set to yellow in this rule?
h2 {
font-size: 20px;
background-color: yellow;
font-style: italic;
margin: 10px;
} (a) margin (b) yellow (c) background-color (d) padding - 33.🎯 Which element does the selector div style? (a) <p class="red"> (b) <h1 id="logo"> (c) <div class="red"> (d) <span>
- 34.True or false: JavaScript puts a picture on a page. (a) True (b) False
- 35.What does background-color do? (a) makes the text bold (b) centres a heading (c) colours behind the text (d) sets the letter colour
- 36.🌈 Hex digits go 0 to 9, then A to which letter? (a) F (b) Z (c) J (d) G
-
37.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 22px;
}
} (a) Yes (b) No -
38.✍️ Which property is set to 8px in this rule?
.note {
font-weight: bold;
padding: 8px;
} (a) padding (b) border (c) font-weight (d) 8px - 39.Which of these is the border? (a) the gap round content (b) space inside the border (c) space outside the border (d) the line round the box
- 40.True or false: padding is space inside the border. (a) False (b) True
Answer key
- False
- h1
- an id selector
- <style>
- #ffff00
- No
- #
- True
- black
- 124
- rounds box corners
- False
- orange
- True
- white
- sets colours and fonts
- { }
- checks a quiz answer
- 172
- an element selector
- orange
- False
- .
- red
- h1
- adds space around boxes
- 2px solid
- JavaScript
- 30
- purple
- 600px or narrower
- background-color
- <div class="red">
- False
- colours behind the text
- F
- Yes
- padding
- the line round the box
- True
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids