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 colour is the text of this element?
<h1 class="note" id="logo">Hi</h1>
CSS:
h1 { color: black; }
h1 { color: red; } (a) white (b) yellow (c) black (d) red - 2.🎯 Which element does the selector p style? (a) <p class="box"> (b) <li id="logo"> (c) <h2 class="box"> (d) <h1>
- 3.🌈 Which colour of light is strongest in rgb(113, 173, 128)? (a) red (b) blue (c) green
-
4.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 80px;
padding: 25px;
border: 1px solid black;
margin: 10px;
} - 5.🎯 What kind of selector is #logo? (a) a class selector (b) an element selector (c) an id selector
- 6.🌈 Which hex code is white? (a) #00ffff (b) #ffffff (c) #ff00ff (d) #ff0000
- 7.True or false: CSS lays out the page. (a) False (b) True
- 8.🌈 Hex digits go 0 to 9, then A to which letter? (a) F (b) J (c) G (d) Z
- 9.🌈 In #5a0000 the red part is the hex number 5a. What is it as a normal number?
- 10.📦 In the box model, which part is space outside the border? (a) content (b) padding (c) margin (d) border
- 11.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the first one (c) the later one (d) neither
-
12.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 270px;
padding: 10px;
border: 3px solid black;
margin: 5px;
} -
13.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 180px;
padding: 10px;
border: 2px solid black;
margin: 5px;
} -
14.⚖️ What colour is the text of this element?
<p class="box" id="main">Hi</p>
CSS:
#main { color: purple; }
p { color: red; } (a) red (b) white (c) black (d) purple - 15.True or false: margin is space outside the border. (a) True (b) False
-
16.✍️ What value is given to border in this rule?
p {
width: 300px;
border: 2px solid;
} (a) italic (b) 300px (c) border (d) 2px solid -
17.⚖️ What colour is the text of this element?
<p class="red" id="intro">Hi</p>
CSS:
.red { color: purple; }
#intro { color: blue; }
p { color: red; } (a) red (b) blue (c) purple (d) orange -
18.🖌️ Where does the text sit on its line?
h2 {
color: green;
background-color: red;
text-align: center;
font-size: 24px;
} (a) on the left (b) on the right (c) in the middle - 19.✍️ Which sign goes between a property and its value? (a) ; (b) - (c) : (d) =
-
20.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} -
21.🖌️ What colour are the letters?
li {
background-color: purple;
font-size: 12px;
text-align: center;
color: orange;
} (a) purple (b) blue (c) orange -
22.🎯 Which CSS selector matches this element?
<p class="star" id="end">Hello</p> (a) #star (b) p (c) .end (d) h1 - 23.🎯 What kind of selector is h1? (a) an id selector (b) a class selector (c) an element selector
- 24.What does text-align do? (a) sets the letter colour (b) picks the font style (c) centres a heading (d) makes the text bold
-
25.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 190px;
justify-content: space-between;
}
Inside are 4 boxes, each 40px wide (no margins). - 26.🔍 Which is the odd one out? (a) changes the page live (b) changes the text size (c) reacts to a button click (d) checks a quiz answer
-
27.✍️ What is the selector in this CSS rule?
h2 {
font-weight: bold;
text-align: center;
} (a) h1 (b) h2 (c) font-weight (d) center - 28.🔍 Which is the odd one out? (a) rounds box corners (b) makes headings and lists (c) gives the page structure (d) puts a picture on a page
- 29.🌈 Which colour is #ff00ff? (a) black (b) yellow (c) white (d) magenta
- 30.🌈 Which hex code is magenta? (a) #00ffff (b) #ffffff (c) #000000 (d) #ff00ff
- 31.🎯 What kind of selector is .menu? (a) an id selector (b) a class selector (c) an element selector
- 32.🔍 Which is the odd one out? (a) sets colours and fonts (b) makes headings and lists (c) gives the page structure (d) makes a form box
- 33.🌈 Which colour is rgb(255, 255, 0)? (a) cyan (b) red (c) yellow (d) bright green
-
34.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 1024px) {
p {
font-size: 24px;
}
} (a) Yes (b) No -
35.⚖️ What colour is the text of this element?
<h1 class="star" id="end">Hi</h1>
CSS:
.star { color: green; }
h1 { color: white; }
#end { color: black; } (a) green (b) white (c) black (d) red - 36.True or false: .big is a class selector. (a) False (b) True
- 37.✍️ Which sign ends each CSS declaration? (a) , (b) : (c) . (d) ;
-
38.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 40px;
padding: 25px;
border: 5px solid black;
margin: 5px;
} -
39.⚖️ What colour is the text of this element?
<h2 class="box" id="intro">Hi</h2>
CSS:
#intro { color: white; }
h2 { color: black; } (a) green (b) white (c) yellow (d) black - 40.What does font-size do? (a) makes letters bigger (b) picks the font style (c) makes the text bold (d) centres a heading
Answer key
- red
- <p class="box">
- green
- 152
- an id selector
- #ffffff
- True
- F
- 90
- margin
- the later one
- 306
- 214
- purple
- True
- 2px solid
- blue
- in the middle
- :
- 10
- orange
- p
- an element selector
- centres a heading
- 10
- changes the text size
- h2
- rounds box corners
- magenta
- #ff00ff
- a class selector
- sets colours and fonts
- yellow
- No
- black
- True
- ;
- 110
- white
- makes letters bigger
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids