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 sign starts a class selector? (a) # (b) & (c) . (d) @
-
2.✍️ Which property is set to 20px in this rule?
.note {
font-style: italic;
font-weight: bold;
font-size: 20px;
} (a) background-color (b) text-align (c) font-size (d) 20px - 3.True or false: margin is space inside the border. (a) False (b) True
- 4.✍️ Which sign ends each CSS declaration? (a) : (b) . (c) ; (d) ,
-
5.🎯 Which CSS selector matches this element?
<h1 class="note" id="logo">Hello</h1> (a) .note (b) #note (c) h2 (d) #end - 6.📦 In the box model, which part is the text or picture? (a) content (b) margin (c) border (d) padding
- 7.💪 Which flexbox property spaces boxes along a row? (a) display: flex (b) align-items (c) gap (d) justify-content
-
8.✍️ What is the selector in this CSS rule?
p {
background-color: yellow;
padding: 8px;
margin: 10px;
color: red;
} (a) .note (b) background-color (c) 8px (d) p -
9.✍️ What is the selector in this CSS rule?
.box {
font-size: 20px;
background-color: yellow;
text-align: center;
} (a) h2 (b) font-size (c) .box (d) yellow - 10.🌈 In #00ec00 the green part is the hex number ec. What is it as a normal number?
- 11.🧩 Which language puts a picture on a page? (a) JavaScript (b) HTML (c) CSS
-
12.🖌️ What colour are the letters?
h1 {
background-color: orange;
color: green;
text-align: right;
font-size: 20px;
} (a) orange (b) black (c) green - 13.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) turned off (c) 800px or wider (d) exactly 100px
- 14.🎨 Which tag connects an outside CSS file? (a) <a> (b) <css> (c) <link> (d) <img>
-
15.🎯 Which CSS selector matches this element?
<h1 class="note" id="end">Hello</h1> (a) .big (b) #note (c) #end (d) #hero -
16.✍️ What value is given to text-align in this rule?
p {
font-weight: bold;
text-align: center;
} (a) 10px (b) yellow (c) text-align (d) center - 17.🔍 Which is the odd one out? (a) puts a picture on a page (b) makes headings and lists (c) shows a pop-up message (d) makes a link
- 18.🎨 What does CSS stand for? (a) Cascading Style Sheets (b) Computer Style Sheets (c) Colourful Site Styles (d) Creative Sheet System
- 19.What does text-align do? (a) makes the text bold (b) colours behind the text (c) centres a heading (d) sets the letter colour
-
20.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} - 21.🎯 Which element does the selector .note style? (a) <span id="note"> (b) <span class="big"> (c) <span class="note"> (d) <p class="red">
-
22.🎯 Which CSS selector matches this element?
<li class="menu" id="top">Hello</li> (a) #intro (b) #menu (c) .note (d) #top -
23.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-weight: bold;
background-color: yellow;
} - 24.🌈 In #rrggbb, which colour do the first two digits give? (a) black (b) red (c) blue (d) green
-
25.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 8px;
}
} (a) No (b) Yes - 26.True or false: JavaScript gives the page structure. (a) True (b) False
- 27.🌈 In #e30000 the red part is the hex number e3. What is it as a normal number?
-
28.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 230px;
padding: 25px;
border: 4px solid black;
margin: 10px;
} -
29.⚖️ What colour is the text of this element?
<p class="note" id="main">Hi</p>
CSS:
p { color: yellow; }
.note { color: blue; }
#main { color: green; } (a) blue (b) yellow (c) purple (d) green - 30.🌈 Which colour is #000000? (a) black (b) yellow (c) bright green (d) blue
- 31.True or false: CSS changes the text size. (a) False (b) True
-
32.🎯 Which CSS selector matches this element?
<p class="red" id="intro">Hello</p> (a) h1 (b) #main (c) .box (d) p - 33.Which of these does JavaScript do? (a) sets colours and fonts (b) makes a link (c) puts a picture on a page (d) checks a quiz answer
- 34.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 2 (b) 6 (c) 4 (d) 3
- 35.🎯 Can many elements share the same class? (a) No (b) Yes
- 36.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the later one (c) the first one (d) the shorter one
-
37.✍️ What is the selector in this CSS rule?
h2 {
text-align: center;
margin: 10px;
} (a) text-align (b) h2 (c) 10px (d) h1 -
38.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} -
39.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 280px;
justify-content: space-between;
}
Inside are 3 boxes, each 80px wide (no margins). - 40.📦 In the box model, which part is space outside the border? (a) border (b) content (c) margin (d) padding
Answer key
- .
- font-size
- False
- ;
- .note
- content
- justify-content
- p
- .box
- 236
- HTML
- green
- 800px or wider
- <link>
- #end
- center
- shows a pop-up message
- Cascading Style Sheets
- centres a heading
- 18
- <span class="note">
- #top
- 2
- red
- No
- False
- 227
- 288
- green
- black
- True
- p
- checks a quiz answer
- 3
- Yes
- the later one
- h2
- 10
- 20
- margin
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids