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 selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
-
2.🖌️ How big is the text, in px?
h1 {
color: yellow;
font-size: 24px;
text-align: center;
background-color: black;
} -
3.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 140px;
padding: 15px;
border: 1px solid black;
margin: 20px;
} -
4.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} (a) Yes (b) No -
5.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 1024px) {
p {
font-size: 14px;
}
} - 6.True or false: JavaScript makes a link. (a) False (b) True
- 7.✍️ Which sign ends each CSS declaration? (a) ; (b) . (c) : (d) ,
- 8.🎯 Which sign starts an id selector? (a) & (b) # (c) @ (d) .
-
9.🖌️ How big is the text, in px?
p {
background-color: red;
color: orange;
font-size: 36px;
text-align: left;
} - 10.Which of these does JavaScript do? (a) sets colours and fonts (b) reacts to a button click (c) changes the text size (d) gives the page structure
-
11.✍️ What value is given to width in this rule?
#top {
width: 300px;
padding: 8px;
font-style: italic;
} (a) width (b) red (c) 300px (d) italic - 12.💪 Which flexbox property lines boxes up across? (a) gap (b) flex-direction (c) align-items (d) justify-content
-
13.⚖️ What colour is the text of this element?
<h2 class="box" id="top">Hi</h2>
CSS:
#top { color: black; }
#top { color: red; } (a) blue (b) yellow (c) black (d) red -
14.✍️ What is the selector in this CSS rule?
h2 {
text-align: center;
font-size: 20px;
width: 300px;
} (a) 20px (b) h1 (c) h2 (d) text-align - 15.📱 What does a media query check? (a) the time of day (b) the page title (c) the battery level (d) the screen width
-
16.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 1024px) {
p {
font-size: 28px;
}
} (a) Yes (b) No -
17.🎯 Which CSS selector matches this element?
<h1 class="big" id="logo">Hello</h1> (a) #end (b) #big (c) h1 (d) h2 -
18.🖌️ What colour are the letters?
h1 {
background-color: green;
color: blue;
text-align: left;
font-size: 40px;
} (a) green (b) yellow (c) blue -
19.🖌️ What colour are the letters?
li {
background-color: purple;
text-align: left;
font-size: 28px;
color: blue;
} (a) purple (b) black (c) blue - 20.📦 In the box model, which part is the gap round content? (a) margin (b) border (c) padding (d) content
-
21.✍️ What is the selector in this CSS rule?
li {
color: red;
border: 2px solid;
} (a) li (b) color (c) 2px solid (d) body - 22.🌈 Which colour of light is strongest in rgb(81, 36, 158)? (a) green (b) blue (c) red
- 23.🎯 What kind of selector is #logo? (a) an element selector (b) a class selector (c) an id selector
-
24.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 200px;
padding: 15px;
border: 4px solid black;
margin: 5px;
} - 25.🔍 Which is the odd one out? (a) makes a form box (b) sets colours and fonts (c) makes headings and lists (d) gives the page structure
- 26.Which of these does CSS do? (a) counts down a timer (b) makes headings and lists (c) puts a picture on a page (d) sets colours and fonts
- 27.✍️ How does a CSS comment start? (a) # (b) /* (c) // (d) <!--
-
28.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 20px;
}
} (a) No (b) Yes - 29.✍️ In color: blue; which part is the value? (a) blue (b) ; (c) : (d) color
- 30.🎨 Which tag holds CSS inside the head? (a) <css> (b) <style> (c) <body> (d) <script>
-
31.🎯 Which CSS selector matches this element?
<h2 class="star" id="main">Hello</h2> (a) li (b) #star (c) #main (d) .menu -
32.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 320px;
justify-content: space-between;
}
Inside are 3 boxes, each 80px wide (no margins). - 33.🧩 Which language puts a picture on a page? (a) JavaScript (b) HTML (c) CSS
-
34.✍️ How many declarations (property: value pairs) are in this rule?
.box {
padding: 8px;
text-align: center;
width: 300px;
} - 35.🧩 Which language gives the page structure? (a) JavaScript (b) CSS (c) HTML
- 36.📱 Responsive design means a page ___. (a) fits every screen (b) is only for laptops (c) never changes (d) has no pictures
- 37.🖌️ Which CSS property colours behind the text? (a) font-size (b) text-align (c) font-weight (d) background-color
- 38.🖌️ Which CSS property makes letters bigger? (a) color (b) text-align (c) font-family (d) font-size
-
39.✍️ What value is given to padding in this rule?
h2 {
color: red;
margin: 10px;
padding: 8px;
font-style: italic;
} (a) bold (b) 8px (c) 2px solid (d) padding -
40.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 60px;
padding: 5px;
border: 3px solid black;
margin: 10px;
}
Answer key
- an id selector
- 24
- 172
- No
- 20
- False
- ;
- #
- 36
- reacts to a button click
- 300px
- align-items
- red
- h2
- the screen width
- No
- h1
- blue
- blue
- padding
- li
- blue
- an id selector
- 238
- sets colours and fonts
- sets colours and fonts
- /*
- No
- blue
- <style>
- #main
- 40
- HTML
- 3
- HTML
- fits every screen
- background-color
- font-size
- 8px
- 96
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids