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 does a media query check? (a) the battery level (b) the page title (c) the time of day (d) the screen width
-
2.✍️ What value is given to background-color in this rule?
body {
border: 2px solid;
background-color: yellow;
font-weight: bold;
width: 300px;
} (a) 10px (b) 8px (c) background-color (d) yellow -
3.✍️ What value is given to margin in this rule?
.note {
margin: 10px;
width: 300px;
font-size: 20px;
font-style: italic;
} (a) 8px (b) bold (c) 10px (d) margin - 4.🌈 In #8a0000 the red part is the hex number 8a. What is it as a normal number?
-
5.⚖️ What colour is the text of this element?
<h1 class="big" id="intro">Hi</h1>
CSS:
#intro { color: red; }
#intro { color: purple; } (a) black (b) red (c) purple (d) yellow -
6.⚖️ What colour is the text of this element?
<p class="menu" id="main">Hi</p>
CSS:
p { color: green; }
#main { color: red; }
.menu { color: yellow; } (a) green (b) red (c) yellow (d) orange - 7.🎯 What kind of selector is h1? (a) an id selector (b) an element selector (c) a class selector
- 8.🌈 Which colour is rgb(0, 255, 0)? (a) blue (b) bright green (c) black (d) white
- 9.🌈 Which colour is rgb(0, 0, 255)? (a) cyan (b) red (c) blue (d) yellow
- 10.True or false: .menu is an id selector. (a) True (b) False
- 11.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
-
12.⚖️ What colour is the text of this element?
<h2 class="red" id="intro">Hi</h2>
CSS:
h2 { color: white; }
h2 { color: blue; } (a) blue (b) white (c) yellow (d) green - 13.📦 In the box model, which part is the line round the box? (a) content (b) margin (c) border (d) padding
-
14.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 80px;
padding: 30px;
border: 3px solid black;
margin: 5px;
} -
15.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 180px;
padding: 15px;
border: 4px solid black;
margin: 5px;
} - 16.🌈 In #00006a the blue part is the hex number 6a. What is it as a normal number?
-
17.🖌️ Where does the text sit on its line?
li {
text-align: right;
background-color: white;
color: purple;
font-size: 32px;
} (a) on the left (b) in the middle (c) on the right -
18.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 8px;
}
} -
19.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 260px;
justify-content: center;
}
Inside are 4 boxes, each 60px wide (no margins). -
20.📦 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: 2px solid black;
margin: 15px;
} -
21.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 180px;
padding: 30px;
border: 1px solid black;
margin: 10px;
} - 22.Which of these does HTML do? (a) sets colours and fonts (b) adds space around boxes (c) shows a pop-up message (d) makes a link
-
23.✍️ How many declarations (property: value pairs) are in this rule?
p {
background-color: yellow;
color: red;
font-size: 20px;
} - 24.✍️ CSS declarations go inside which brackets? (a) { } (b) < > (c) [ ] (d) ( )
- 25.🧩 Which language changes the text size? (a) JavaScript (b) CSS (c) HTML
- 26.🌈 Which colour is #ffffff? (a) black (b) red (c) cyan (d) white
- 27.🌈 Which colour is rgb(0, 0, 0)? (a) blue (b) cyan (c) yellow (d) black
- 28.🔍 Which is the odd one out? (a) makes a form box (b) gives the page structure (c) puts a picture on a page (d) rounds box corners
- 29.💪 Which flexbox property spaces boxes along a row? (a) justify-content (b) align-items (c) gap (d) flex-direction
-
30.🖌️ Where does the text sit on its line?
h2 {
text-align: center;
background-color: red;
color: blue;
font-size: 12px;
} (a) on the right (b) in the middle (c) on the left - 31.🧩 Which language adds space around boxes? (a) JavaScript (b) HTML (c) CSS
-
32.⚖️ What colour is the text of this element?
<h1 class="red" id="hero">Hi</h1>
CSS:
.red { color: white; }
#hero { color: orange; }
h1 { color: yellow; } (a) orange (b) yellow (c) white (d) black -
33.⚖️ What colour is the text of this element?
<h1 class="red" id="intro">Hi</h1>
CSS:
#intro { color: orange; }
#intro { color: yellow; } (a) orange (b) red (c) yellow (d) purple - 34.🎯 Can many elements share the same class? (a) No (b) Yes
- 35.✍️ In color: blue; which part is the value? (a) : (b) blue (c) ; (d) color
- 36.🌈 In #000032 the blue part is the hex number 32. What is it as a normal number?
-
37.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
color: red;
} -
38.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-style: italic;
} - 39.🌈 Which colour is #ffff00? (a) bright green (b) yellow (c) blue (d) red
-
40.🖌️ What colour are the letters?
li {
background-color: black;
font-size: 24px;
color: blue;
text-align: right;
} (a) blue (b) orange (c) black
Answer key
- the screen width
- yellow
- 10px
- 138
- purple
- red
- an element selector
- bright green
- blue
- False
- an id selector
- blue
- border
- 156
- 228
- 106
- on the right
- 8
- 10
- 94
- 262
- makes a link
- 3
- { }
- CSS
- white
- black
- rounds box corners
- justify-content
- in the middle
- CSS
- orange
- yellow
- Yes
- blue
- 50
- 1
- 1
- yellow
- blue
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids