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?
<h2 class="menu" id="top">Hi</h2>
CSS:
h2 { color: black; }
h2 { color: yellow; } (a) blue (b) black (c) yellow (d) red - 2.True or false: .card is a class selector. (a) True (b) False
-
3.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} (a) No (b) Yes -
4.🖌️ How big is the text, in px?
h2 {
text-align: left;
background-color: orange;
font-size: 16px;
color: white;
} - 5.True or false: the content is space outside the border. (a) False (b) True
-
6.✍️ What value is given to border in this rule?
.box {
font-style: italic;
font-weight: bold;
border: 2px solid;
} (a) italic (b) 2px solid (c) border (d) 300px - 7.Which of these is margin? (a) the gap round content (b) the gap to other boxes (c) a solid or dotted edge (d) space inside the border
- 8.What does text-align do? (a) picks the font style (b) centres a heading (c) colours behind the text (d) makes the text bold
- 9.🧩 Which language gives the page structure? (a) JavaScript (b) HTML (c) CSS
- 10.🌈 Which colour is #00ff00? (a) magenta (b) cyan (c) red (d) bright green
- 11.🎯 Which element does the selector #end style? (a) <div id="end"> (b) <div class="end"> (c) <span class="red"> (d) <div id="hero">
-
12.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 220px;
justify-content: center;
}
Inside are 3 boxes, each 60px wide (no margins). -
13.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 230px;
padding: 20px;
border: 5px solid black;
margin: 0px;
} - 14.🎯 Which sign starts an id selector? (a) . (b) # (c) & (d) @
- 15.Which of these does HTML do? (a) sets colours and fonts (b) reacts to a button click (c) makes headings and lists (d) changes the page live
- 16.🌈 In #rrggbb, which colour do the first two digits give? (a) blue (b) black (c) red (d) green
-
17.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 1024px) {
p {
font-size: 22px;
}
} - 18.🖌️ Which CSS property sets the letter colour? (a) font-size (b) background-color (c) color (d) text-align
- 19.🎨 Which attribute adds CSS inside one tag? (a) href (b) src (c) style (d) alt
-
20.✍️ Which property is set to center in this rule?
.box {
text-align: center;
color: red;
} (a) margin (b) background-color (c) text-align (d) center -
21.✍️ What value is given to font-style in this rule?
h1 {
font-style: italic;
border: 2px solid;
font-size: 20px;
text-align: center;
} (a) red (b) font-style (c) italic (d) 20px -
22.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 250px;
justify-content: flex-end;
}
Inside are 4 boxes, each 50px wide (no margins). -
23.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 24px;
}
} (a) Yes (b) No - 24.🎨 Which tag connects an outside CSS file? (a) <link> (b) <img> (c) <css> (d) <a>
-
25.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 1024px) {
p {
font-size: 28px;
}
} -
26.✍️ What is the selector in this CSS rule?
.box {
text-align: center;
background-color: yellow;
} (a) h2 (b) text-align (c) .box (d) yellow -
27.✍️ What value is given to padding in this rule?
#top {
padding: 8px;
width: 300px;
border: 2px solid;
background-color: yellow;
} (a) padding (b) 2px solid (c) 8px (d) bold -
28.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 160px;
padding: 30px;
border: 4px solid black;
margin: 15px;
} - 29.True or false: margin is space outside the border. (a) True (b) False
-
30.🖌️ What colour are the letters?
p {
text-align: left;
font-size: 16px;
background-color: blue;
color: red;
} (a) red (b) black (c) blue - 31.🔍 Which is the odd one out? (a) changes the page live (b) reacts to a button click (c) shows a pop-up message (d) rounds box corners
- 32.🎯 Which element does the selector #top style? (a) <h1 id="intro"> (b) <h1 id="top"> (c) <h2 class="note"> (d) <h1 class="top">
-
33.⚖️ What colour is the text of this element?
<h2 class="star" id="hero">Hi</h2>
CSS:
h2 { color: black; }
.star { color: green; } (a) green (b) red (c) black (d) orange - 34.✍️ Which sign goes between a property and its value? (a) = (b) : (c) ; (d) -
-
35.🎯 Which CSS selector matches this element?
<h1 class="red" id="end">Hello</h1> (a) #hero (b) .end (c) #end (d) h2 -
36.✍️ How many declarations (property: value pairs) are in this rule?
body {
color: red;
border: 2px solid;
font-style: italic;
font-size: 20px;
} -
37.🎯 Which CSS selector matches this element?
<span class="menu" id="main">Hello</span> (a) .menu (b) #menu (c) p (d) .main - 38.What does background-color do? (a) makes the text bold (b) picks the font style (c) sets the letter colour (d) colours behind the text
- 39.🧩 Which language sets colours and fonts? (a) HTML (b) JavaScript (c) CSS
-
40.🎯 Which CSS selector matches this element?
<span class="star" id="top">Hello</span> (a) .top (b) p (c) #intro (d) #top
Answer key
- yellow
- True
- Yes
- 16
- False
- 2px solid
- the gap to other boxes
- centres a heading
- HTML
- bright green
- <div id="end">
- 20
- 280
- #
- makes headings and lists
- red
- 22
- color
- style
- text-align
- italic
- 50
- No
- <link>
- 24
- .box
- 8px
- 258
- True
- red
- rounds box corners
- <h1 id="top">
- green
- :
- #end
- 4
- .menu
- colours behind the text
- CSS
- #top
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids