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 is the selector in this CSS rule?
h1 {
font-size: 20px;
width: 300px;
} (a) 300px (b) h1 (c) p (d) font-size - 2.🌈 Which colour is #0000ff? (a) magenta (b) cyan (c) blue (d) bright green
-
3.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 170px;
padding: 20px;
border: 2px solid black;
margin: 20px;
} - 4.🎯 Which element does the selector #end style? (a) <li class="end"> (b) <div class="box"> (c) <li id="end"> (d) <li id="hero">
- 5.True or false: body is a class selector. (a) False (b) True
-
6.✍️ What value is given to padding in this rule?
.note {
width: 300px;
font-style: italic;
font-weight: bold;
padding: 8px;
} (a) padding (b) bold (c) 2px solid (d) 8px - 7.Which of these is margin? (a) the line round the box (b) a solid or dotted edge (c) space outside the border (d) the text or picture
- 8.✍️ In color: blue; which part is the property? (a) blue (b) : (c) color (d) ;
- 9.Which of these does HTML do? (a) checks a quiz answer (b) shows a pop-up message (c) makes a link (d) changes the text size
-
10.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 26px;
}
} (a) Yes (b) No - 11.📱 What does a media query check? (a) the page title (b) the time of day (c) the screen width (d) the battery level
- 12.🌈 Which hex code is red? (a) #00ff00 (b) #ff00ff (c) #ff0000 (d) #0000ff
- 13.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
-
14.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 70px;
padding: 10px;
border: 4px solid black;
margin: 20px;
} - 15.🖌️ Which CSS property makes the text bold? (a) background-color (b) font-weight (c) text-align (d) font-size
- 16.🧩 Which language makes headings and lists? (a) CSS (b) JavaScript (c) HTML
- 17.🌈 Which colour is rgb(0, 0, 0)? (a) red (b) yellow (c) bright green (d) black
- 18.🎨 A CSS file usually ends with which extension? (a) .png (b) .html (c) .js (d) .css
- 19.True or false: JavaScript gives the page structure. (a) False (b) True
-
20.🖌️ How big is the text, in px?
h2 {
font-size: 28px;
color: yellow;
text-align: center;
background-color: black;
} - 21.True or false: .big is an element selector. (a) False (b) True
- 22.✍️ CSS declarations go inside which brackets? (a) < > (b) [ ] (c) ( ) (d) { }
- 23.📦 In the box model, which part is space outside the border? (a) border (b) margin (c) content (d) padding
- 24.🎯 Which element does the selector .box style? (a) <h2 class="menu"> (b) <h1 id="box"> (c) <h1 class="box"> (d) <h1 class="star">
- 25.✍️ How does a CSS comment start? (a) # (b) <!-- (c) // (d) /*
-
26.✍️ How many declarations (property: value pairs) are in this rule?
li {
width: 300px;
margin: 10px;
} -
27.⚖️ What colour is the text of this element?
<h1 class="big" id="top">Hi</h1>
CSS:
#top { color: black; }
h1 { color: blue; }
.big { color: orange; } (a) blue (b) green (c) orange (d) black - 28.🌈 Which hex code is white? (a) #ff00ff (b) #000000 (c) #ff0000 (d) #ffffff
-
29.🖌️ How big is the text, in px?
h1 {
font-size: 36px;
background-color: blue;
text-align: left;
color: red;
} - 30.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
- 31.🎯 Which sign starts a class selector? (a) # (b) . (c) @ (d) &
- 32.🔍 Which is the odd one out? (a) reacts to a button click (b) makes headings and lists (c) changes the page live (d) shows a pop-up message
- 33.Which of these is the content? (a) the text or picture (b) the gap round content (c) the line round the box (d) space inside the border
-
34.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 26px;
}
} (a) Yes (b) No -
35.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 140px;
justify-content: center;
}
Inside are 2 boxes, each 50px wide (no margins). -
36.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 140px;
padding: 10px;
border: 2px solid black;
margin: 0px;
} - 37.✍️ Which sign goes between a property and its value? (a) : (b) - (c) ; (d) =
-
38.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 20px;
}
} - 39.🌈 Which hex code is black? (a) #000000 (b) #ffff00 (c) #00ff00 (d) #ff0000
-
40.✍️ How many declarations (property: value pairs) are in this rule?
li {
width: 300px;
background-color: yellow;
color: red;
}
Answer key
- h1
- blue
- 254
- <li id="end">
- False
- 8px
- space outside the border
- color
- makes a link
- No
- the screen width
- #ff0000
- an element selector
- 98
- font-weight
- HTML
- black
- .css
- False
- 28
- False
- { }
- margin
- <h1 class="box">
- /*
- 2
- black
- #ffffff
- 36
- an id selector
- .
- makes headings and lists
- the text or picture
- Yes
- 20
- 164
- :
- 20
- #000000
- 3
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids