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 CSS selector matches this element?
<span class="note" id="intro">Hello</span> (a) span (b) .intro (c) #main (d) p - 2.✍️ Which sign goes between a property and its value? (a) - (b) = (c) : (d) ;
-
3.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 110px;
padding: 30px;
border: 3px solid black;
margin: 10px;
} - 4.True or false: .big is an element selector. (a) True (b) False
- 5.🌈 Hex digits go 0 to 9, then A to which letter? (a) Z (b) G (c) F (d) J
- 6.Which of these does JavaScript do? (a) reacts to a button click (b) changes the text size (c) adds space around boxes (d) makes headings and lists
- 7.🔍 Which is the odd one out? (a) gives the page structure (b) lays out the page (c) sets colours and fonts (d) adds space around boxes
- 8.🖌️ Which CSS property makes letters bigger? (a) text-align (b) font-family (c) font-size (d) font-weight
- 9.Which of these does CSS do? (a) puts a picture on a page (b) makes a link (c) gives the page structure (d) rounds box corners
- 10.What does background-color do? (a) colours behind the text (b) sets the letter colour (c) picks the font style (d) centres a heading
-
11.✍️ How many declarations (property: value pairs) are in this rule?
li {
text-align: center;
} - 12.True or false: JavaScript counts down a timer. (a) False (b) True
- 13.📦 In the box model, which part is the gap round content? (a) content (b) margin (c) padding (d) border
- 14.True or false: HTML shows a pop-up message. (a) False (b) True
- 15.🎯 What kind of selector is #hero? (a) an id selector (b) an element selector (c) a class selector
- 16.🎨 Which tag connects an outside CSS file? (a) <link> (b) <img> (c) <css> (d) <a>
-
17.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
border: 2px solid;
color: red;
text-align: center;
background-color: yellow;
} -
18.⚖️ What colour is the text of this element?
<h1 class="box" id="end">Hi</h1>
CSS:
#end { color: white; }
#end { color: black; } (a) black (b) white (c) purple (d) blue -
19.🖌️ Where does the text sit on its line?
h2 {
font-size: 28px;
text-align: right;
color: black;
background-color: purple;
} (a) on the right (b) on the left (c) in the middle -
20.✍️ What is the selector in this CSS rule?
h2 {
font-size: 20px;
margin: 10px;
} (a) h2 (b) h1 (c) font-size (d) 10px - 21.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
- 22.🌈 Which hex code is cyan? (a) #ff00ff (b) #0000ff (c) #ffffff (d) #00ffff
-
23.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 18px;
}
} -
24.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 190px;
padding: 10px;
border: 3px solid black;
margin: 20px;
} -
25.⚖️ What colour is the text of this element?
<h1 class="menu" id="end">Hi</h1>
CSS:
.menu { color: white; }
#end { color: orange; }
h1 { color: black; } (a) orange (b) white (c) black (d) red - 26.🧩 Which language checks a quiz answer? (a) CSS (b) HTML (c) JavaScript
- 27.What does font-family do? (a) picks the font style (b) makes letters bigger (c) centres a heading (d) makes the text bold
- 28.What does justify-content: space-between do? (a) puts boxes in the middle (b) packs boxes at the end (c) equal gaps, none at ends (d) packs boxes at the start
-
29.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 130px;
padding: 25px;
border: 1px solid black;
margin: 0px;
} - 30.🌈 In #00dc00 the green part is the hex number dc. What is it as a normal number?
- 31.🧩 Which language lays out the page? (a) HTML (b) JavaScript (c) CSS
- 32.🎯 What kind of selector is p? (a) an id selector (b) a class selector (c) an element selector
-
33.🎯 Which CSS selector matches this element?
<span class="big" id="end">Hello</span> (a) #big (b) span (c) .red (d) #hero - 34.What does justify-content: flex-end do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the start (d) packs boxes at the end
-
35.⚖️ What colour is the text of this element?
<h2 class="big" id="main">Hi</h2>
CSS:
.big { color: black; }
#main { color: green; }
h2 { color: purple; } (a) purple (b) green (c) white (d) black -
36.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 130px;
justify-content: flex-end;
}
Inside are 2 boxes, each 60px wide (no margins). - 37.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) red (c) white (d) blue
-
38.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 350px;
justify-content: flex-start;
}
Inside are 4 boxes, each 80px wide (no margins). - 39.True or false: .card is a class selector. (a) True (b) False
- 40.True or false: CSS checks a quiz answer. (a) True (b) False
Answer key
- span
- :
- 196
- False
- F
- reacts to a button click
- gives the page structure
- font-size
- rounds box corners
- colours behind the text
- 1
- True
- padding
- False
- an id selector
- <link>
- 4
- black
- on the right
- h2
- an id selector
- #00ffff
- 12
- 256
- orange
- JavaScript
- picks the font style
- equal gaps, none at ends
- 182
- 220
- CSS
- an element selector
- span
- packs boxes at the end
- green
- 10
- blue
- 30
- True
- False
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids