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 span style? (a) <h2 id="top"> (b) <p> (c) <h1 class="red"> (d) <span class="red">
- 2.🎯 Which element does the selector #logo style? (a) <p id="end"> (b) <p id="logo"> (c) <h1 class="big"> (d) <p class="logo">
- 3.🎯 How many elements on a page should have the same id? (a) any number (b) 1 (c) 5 (d) 2
-
4.⚖️ What colour is the text of this element?
<h1 class="star" id="hero">Hi</h1>
CSS:
#hero { color: black; }
#hero { color: yellow; } (a) black (b) blue (c) yellow (d) white -
5.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 768px) {
p {
font-size: 12px;
}
} - 6.True or false: JavaScript rounds box corners. (a) True (b) False
-
7.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 150px;
justify-content: space-between;
}
Inside are 2 boxes, each 60px wide (no margins). - 8.Which of these is the content? (a) space outside the border (b) a solid or dotted edge (c) the text or picture (d) space inside the border
- 9.🎯 What kind of selector is #main? (a) an element selector (b) a class selector (c) an id selector
- 10.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the hr tag (c) the viewport meta tag (d) the br tag
- 11.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) 600px or wider (c) 600px or narrower (d) exactly 1000px
-
12.✍️ What is the selector in this CSS rule?
h2 {
font-size: 20px;
font-style: italic;
} (a) h1 (b) italic (c) font-size (d) h2 -
13.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 80px;
padding: 10px;
border: 3px solid black;
margin: 0px;
} -
14.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
font-style: italic;
width: 300px;
} - 15.Which of these does HTML do? (a) reacts to a button click (b) makes headings and lists (c) sets colours and fonts (d) shows a pop-up message
-
16.🖌️ How big is the text, in px?
h1 {
text-align: center;
background-color: purple;
color: white;
font-size: 28px;
} - 17.🧩 Which language gives the page structure? (a) JavaScript (b) CSS (c) HTML
- 18.True or false: CSS changes the text size. (a) False (b) True
- 19.🎯 Which element does the selector #hero style? (a) <h1 id="hero"> (b) <h2 class="big"> (c) <h1 class="hero"> (d) <h1 id="top">
- 20.💪 Which flexbox property picks row or column? (a) display: flex (b) flex-direction (c) align-items (d) justify-content
- 21.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
- 22.What does background-color do? (a) makes letters bigger (b) colours behind the text (c) sets the letter colour (d) makes the text bold
-
23.⚖️ What colour is the text of this element?
<p class="red" id="top">Hi</p>
CSS:
p { color: red; }
#top { color: blue; } (a) black (b) blue (c) orange (d) red - 24.🧩 Which language checks a quiz answer? (a) JavaScript (b) HTML (c) CSS
- 25.🌈 In #rrggbb, which colour do the last two digits give? (a) white (b) blue (c) red (d) green
- 26.🎯 What kind of selector is .note? (a) an id selector (b) an element selector (c) a class selector
-
27.🎯 Which CSS selector matches this element?
<h2 class="big" id="logo">Hello</h2> (a) li (b) .red (c) #big (d) h2 - 28.What does text-align do? (a) sets the letter colour (b) makes letters bigger (c) colours behind the text (d) centres a heading
- 29.🌈 Which colour is rgb(0, 0, 0)? (a) black (b) red (c) bright green (d) cyan
- 30.🧩 Which language makes a link? (a) HTML (b) JavaScript (c) CSS
-
31.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 320px;
justify-content: center;
}
Inside are 2 boxes, each 100px wide (no margins). - 32.✍️ Which sign goes between a property and its value? (a) = (b) ; (c) - (d) :
-
33.✍️ Which property is set to center in this rule?
p {
text-align: center;
width: 300px;
} (a) margin (b) text-align (c) center (d) background-color -
34.⚖️ What colour is the text of this element?
<h1 class="big" id="logo">Hi</h1>
CSS:
#logo { color: orange; }
.big { color: green; } (a) green (b) black (c) purple (d) orange -
35.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 768px) {
p {
font-size: 16px;
}
} -
36.✍️ Which property is set to center in this rule?
p {
text-align: center;
font-size: 20px;
font-style: italic;
} (a) background-color (b) text-align (c) margin (d) center - 37.True or false: JavaScript shows a pop-up message. (a) True (b) False
-
38.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 14px;
}
} - 39.🌈 Which colour is #ff0000? (a) white (b) magenta (c) red (d) yellow
-
40.🎯 Which CSS selector matches this element?
<span class="big" id="top">Hello</span> (a) #big (b) #intro (c) span (d) p
Answer key
- <span class="red">
- <p id="logo">
- 1
- yellow
- 12
- False
- 30
- the text or picture
- an id selector
- the viewport meta tag
- 600px or narrower
- h2
- 106
- 2
- makes headings and lists
- 28
- HTML
- True
- <h1 id="hero">
- flex-direction
- an id selector
- colours behind the text
- blue
- JavaScript
- blue
- a class selector
- h2
- centres a heading
- black
- HTML
- 60
- :
- text-align
- orange
- 16
- text-align
- True
- 12
- red
- span
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids