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.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 170px;
padding: 15px;
border: 5px solid black;
margin: 15px;
} - 2.🔍 Which is the odd one out? (a) adds space around boxes (b) changes the text size (c) rounds box corners (d) makes a link
- 3.🖌️ Which CSS property makes the text bold? (a) color (b) text-align (c) font-weight (d) font-family
-
4.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 768px) {
p {
font-size: 20px;
}
} (a) No (b) Yes -
5.🎯 Which CSS selector matches this element?
<span class="box" id="top">Hello</span> (a) #box (b) .box (c) p (d) .star - 6.🧩 Which language changes the text size? (a) JavaScript (b) HTML (c) CSS
- 7.📱 Responsive design means a page ___. (a) is only for laptops (b) never changes (c) fits every screen (d) has no pictures
- 8.What does justify-content: space-between do? (a) packs boxes at the start (b) packs boxes at the end (c) puts boxes in the middle (d) equal gaps, none at ends
- 9.🧩 Which language lays out the page? (a) HTML (b) CSS (c) JavaScript
- 10.🌈 Which colour is rgb(255, 0, 255)? (a) bright green (b) magenta (c) red (d) cyan
- 11.✍️ How does a CSS comment start? (a) # (b) // (c) /* (d) <!--
- 12.🖌️ Which CSS property picks the font style? (a) color (b) text-align (c) background-color (d) font-family
- 13.🎯 What kind of selector is p? (a) a class selector (b) an element selector (c) an id selector
-
14.🖌️ Where does the text sit on its line?
h1 {
background-color: orange;
font-size: 28px;
text-align: center;
color: black;
} (a) on the right (b) on the left (c) in the middle -
15.⚖️ What colour is the text of this element?
<p class="box" id="hero">Hi</p>
CSS:
p { color: red; }
p { color: blue; } (a) blue (b) red (c) purple (d) green - 16.🌈 Which colour is rgb(0, 255, 0)? (a) blue (b) red (c) black (d) bright green
- 17.True or false: li is an element selector. (a) True (b) False
- 18.💪 Which flexbox property spaces boxes along a row? (a) flex-direction (b) align-items (c) justify-content (d) display: flex
- 19.True or false: .menu is an element selector. (a) True (b) False
- 20.🌈 Which colour is #ff00ff? (a) white (b) black (c) yellow (d) magenta
- 21.True or false: #main is an id selector. (a) False (b) True
-
22.✍️ How many declarations (property: value pairs) are in this rule?
body {
background-color: yellow;
margin: 10px;
font-style: italic;
} - 23.True or false: p is an element selector. (a) True (b) False
- 24.True or false: CSS reacts to a button click. (a) False (b) True
- 25.True or false: HTML gives the page structure. (a) False (b) True
- 26.What does justify-content: flex-start do? (a) equal gaps, none at ends (b) packs boxes at the end (c) puts boxes in the middle (d) packs boxes at the start
-
27.✍️ What value is given to font-style in this rule?
#top {
font-style: italic;
font-size: 20px;
text-align: center;
font-weight: bold;
} (a) font-style (b) italic (c) red (d) 20px - 28.True or false: padding is space inside the border. (a) False (b) True
-
29.🎯 Which CSS selector matches this element?
<p class="star" id="logo">Hello</p> (a) .logo (b) .star (c) #end (d) #star - 30.📦 In the box model, which part is space outside the border? (a) content (b) padding (c) margin (d) border
- 31.True or false: .star is an id selector. (a) False (b) True
- 32.Which of these does HTML do? (a) rounds box corners (b) makes headings and lists (c) shows a pop-up message (d) checks a quiz answer
-
33.⚖️ What colour is the text of this element?
<h2 class="star" id="main">Hi</h2>
CSS:
.star { color: purple; }
#main { color: yellow; } (a) green (b) yellow (c) purple (d) orange - 34.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) neither (c) the later one (d) the shorter one
- 35.📱 Which tag helps phones show a page at the right size? (a) the br tag (b) the viewport meta tag (c) the title tag (d) the hr tag
-
36.✍️ Which property is set to yellow in this rule?
h2 {
background-color: yellow;
color: red;
} (a) margin (b) background-color (c) padding (d) yellow - 37.🎯 How many elements on a page should have the same id? (a) 2 (b) any number (c) 5 (d) 1
- 38.🎯 Which element does the selector h1 style? (a) <li class="menu"> (b) <h2> (c) <div id="top"> (d) <h1 class="menu">
- 39.🔍 Which is the odd one out? (a) checks a quiz answer (b) shows a pop-up message (c) changes the page live (d) puts a picture on a page
- 40.✍️ CSS declarations go inside which brackets? (a) ( ) (b) { } (c) [ ] (d) < >
Answer key
- 240
- makes a link
- font-weight
- Yes
- .box
- CSS
- fits every screen
- equal gaps, none at ends
- CSS
- magenta
- /*
- font-family
- an element selector
- in the middle
- blue
- bright green
- True
- justify-content
- False
- magenta
- True
- 3
- True
- False
- True
- packs boxes at the start
- italic
- True
- .star
- margin
- False
- makes headings and lists
- yellow
- the later one
- the viewport meta tag
- background-color
- 1
- <h1 class="menu">
- puts a picture on a page
- { }
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids