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 element does the selector #logo style? (a) <li class="logo"> (b) <div class="red"> (c) <li id="logo"> (d) <li id="end">
-
2.✍️ What value is given to font-weight in this rule?
li {
font-style: italic;
font-weight: bold;
color: red;
} (a) font-weight (b) bold (c) 2px solid (d) 300px - 3.🖌️ Which CSS property makes letters bigger? (a) font-size (b) background-color (c) font-family (d) font-weight
- 4.📱 Which tag helps phones show a page at the right size? (a) the br tag (b) the hr tag (c) the viewport meta tag (d) the title tag
-
5.🖌️ What colour is behind the letters?
p {
color: green;
font-size: 40px;
text-align: center;
background-color: red;
} (a) red (b) green (c) blue - 6.🎯 Which element does the selector .red style? (a) <li id="red"> (b) <div class="star"> (c) <li class="red"> (d) <li class="box">
-
7.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 20px;
}
} (a) Yes (b) No -
8.⚖️ What colour is the text of this element?
<p class="star" id="logo">Hi</p>
CSS:
.star { color: black; }
.star { color: red; } (a) red (b) black (c) orange (d) white - 9.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 4 (b) 6 (c) 2 (d) 3
- 10.True or false: .menu is an element selector. (a) True (b) False
- 11.💪 Which flexbox property spaces boxes along a row? (a) display: flex (b) flex-direction (c) justify-content (d) align-items
- 12.📦 In the box model, which part is the gap to other boxes? (a) margin (b) content (c) padding (d) border
-
13.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
font-weight: bold;
margin: 10px;
font-size: 20px;
border: 2px solid;
} -
14.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 480px) {
p {
font-size: 20px;
}
} - 15.🌈 Which colour of light is strongest in rgb(98, 203, 121)? (a) green (b) red (c) blue
-
16.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
padding: 8px;
font-size: 20px;
background-color: yellow;
color: red;
} -
17.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 230px;
justify-content: flex-end;
}
Inside are 2 boxes, each 80px wide (no margins). - 18.🌈 In #000079 the blue part is the hex number 79. What is it as a normal number?
-
19.🖌️ Where does the text sit on its line?
li {
background-color: yellow;
text-align: center;
color: black;
font-size: 20px;
} (a) on the right (b) on the left (c) in the middle -
20.✍️ Which property is set to red in this rule?
#top {
color: red;
padding: 8px;
} (a) red (b) color (c) text-align (d) font-size - 21.True or false: #hero is an element selector. (a) False (b) True
- 22.True or false: HTML makes a link. (a) False (b) True
-
23.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 60px;
padding: 10px;
border: 3px solid black;
margin: 20px;
} -
24.✍️ What is the selector in this CSS rule?
.note {
font-weight: bold;
border: 2px solid;
} (a) 2px solid (b) font-weight (c) .note (d) #top - 25.✍️ In color: blue; which part is the property? (a) ; (b) : (c) blue (d) color
-
26.🎯 Which CSS selector matches this element?
<p class="red" id="main">Hello</p> (a) .main (b) #logo (c) #red (d) #main -
27.🎯 Which CSS selector matches this element?
<li class="box" id="end">Hello</li> (a) #box (b) .box (c) .star (d) div -
28.🎯 Which CSS selector matches this element?
<p class="star" id="intro">Hello</p> (a) .menu (b) #star (c) h1 (d) .star -
29.🖌️ Where does the text sit on its line?
h1 {
background-color: blue;
font-size: 28px;
color: black;
text-align: center;
} (a) on the right (b) in the middle (c) on the left - 30.🧩 Which language puts a picture on a page? (a) CSS (b) HTML (c) JavaScript
- 31.True or false: padding is the gap round content. (a) True (b) False
- 32.🖌️ Which CSS property sets the letter colour? (a) font-size (b) text-align (c) background-color (d) color
- 33.🌈 Which hex code is red? (a) #0000ff (b) #000000 (c) #ff0000 (d) #00ff00
- 34.True or false: the content is space outside the border. (a) False (b) True
- 35.🎯 Which sign starts a class selector? (a) # (b) @ (c) & (d) .
- 36.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or narrower (c) 600px or wider (d) turned off
- 37.What does justify-content: center do? (a) puts boxes in the middle (b) packs boxes at the start (c) equal gaps, none at ends (d) packs boxes at the end
-
38.✍️ How many declarations (property: value pairs) are in this rule?
body {
font-style: italic;
margin: 10px;
border: 2px solid;
} - 39.🎯 Which element does the selector .menu style? (a) <h1 class="note"> (b) <h1 class="menu"> (c) <h1 id="menu"> (d) <h2 class="big">
- 40.📦 In the box model, which part is a solid or dotted edge? (a) margin (b) border (c) padding (d) content
Answer key
- <li id="logo">
- bold
- font-size
- the viewport meta tag
- red
- <li class="red">
- Yes
- red
- 3
- False
- justify-content
- margin
- 4
- 20
- green
- 4
- 70
- 121
- in the middle
- color
- False
- True
- 126
- .note
- color
- #main
- .box
- .star
- in the middle
- HTML
- True
- color
- #ff0000
- False
- .
- 600px or narrower
- puts boxes in the middle
- 3
- <h1 class="menu">
- border
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids