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 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
-
2.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 260px;
padding: 10px;
border: 2px solid black;
margin: 20px;
} -
3.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 160px;
padding: 5px;
border: 4px solid black;
margin: 15px;
} - 4.🔍 Which is the odd one out? (a) sets colours and fonts (b) shows a pop-up message (c) lays out the page (d) rounds box corners
-
5.⚖️ What colour is the text of this element?
<p class="big" id="main">Hi</p>
CSS:
#main { color: green; }
#main { color: purple; } (a) blue (b) white (c) green (d) purple - 6.🧩 Which language reacts to a button click? (a) JavaScript (b) HTML (c) CSS
-
7.✍️ Which property is set to 2px solid in this rule?
p {
border: 2px solid;
margin: 10px;
} (a) font-style (b) border (c) 2px solid (d) width - 8.🌈 Which hex code is yellow? (a) #ff0000 (b) #ffffff (c) #00ffff (d) #ffff00
- 9.✍️ CSS declarations go inside which brackets? (a) [ ] (b) { } (c) < > (d) ( )
- 10.🎯 Which sign starts an id selector? (a) & (b) @ (c) # (d) .
- 11.✍️ How does a CSS comment start? (a) // (b) /* (c) # (d) <!--
-
12.✍️ What value is given to text-align in this rule?
.note {
font-style: italic;
text-align: center;
} (a) center (b) yellow (c) text-align (d) 10px -
13.✍️ Which property is set to italic in this rule?
h2 {
font-style: italic;
width: 300px;
} (a) font-size (b) color (c) italic (d) font-style -
14.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-size: 20px;
padding: 8px;
margin: 10px;
} - 15.📦 In the box model, which part is the text or picture? (a) content (b) border (c) padding (d) margin
-
16.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 28px;
}
} (a) Yes (b) No -
17.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
margin: 10px;
font-weight: bold;
} - 18.🌈 Which colour is rgb(0, 255, 0)? (a) red (b) blue (c) magenta (d) bright green
-
19.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 100px;
justify-content: flex-end;
}
Inside are 2 boxes, each 40px wide (no margins). - 20.✍️ Which sign goes between a property and its value? (a) = (b) ; (c) : (d) -
-
21.✍️ How many declarations (property: value pairs) are in this rule?
.box {
font-style: italic;
} - 22.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or narrower (c) 600px or wider (d) turned off
- 23.🌈 Which colour is #00ff00? (a) yellow (b) white (c) red (d) bright green
-
24.✍️ What value is given to background-color in this rule?
li {
margin: 10px;
width: 300px;
text-align: center;
background-color: yellow;
} (a) 8px (b) background-color (c) yellow (d) 10px -
25.🎯 Which CSS selector matches this element?
<h2 class="menu" id="main">Hello</h2> (a) li (b) #main (c) .note (d) .main -
26.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 160px;
justify-content: flex-end;
}
Inside are 2 boxes, each 50px wide (no margins). -
27.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 210px;
padding: 15px;
border: 3px solid black;
margin: 15px;
} -
28.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 6px;
}
} - 29.💪 Which justify-content value packs boxes at the end? (a) flex-end (b) flex-start (c) center (d) space-between
- 30.✍️ In color: blue; which part is the property? (a) blue (b) : (c) color (d) ;
-
31.✍️ How many declarations (property: value pairs) are in this rule?
body {
border: 2px solid;
margin: 10px;
width: 300px;
color: red;
} - 32.🌈 Which colour is #000000? (a) black (b) cyan (c) blue (d) white
-
33.✍️ What value is given to background-color in this rule?
p {
padding: 8px;
background-color: yellow;
margin: 10px;
} (a) 10px (b) background-color (c) 8px (d) yellow - 34.Which of these does CSS do? (a) reacts to a button click (b) shows a pop-up message (c) lays out the page (d) makes a link
- 35.True or false: CSS changes the text size. (a) True (b) False
-
36.✍️ Which property is set to red in this rule?
h2 {
border: 2px solid;
color: red;
} (a) red (b) color (c) font-size (d) text-align - 37.True or false: #end is an id selector. (a) False (b) True
- 38.True or false: CSS makes a link. (a) False (b) True
- 39.🎯 Which element does the selector h1 style? (a) <h1 class="box"> (b) <div id="logo"> (c) <li class="box"> (d) <h2>
-
40.🎯 Which CSS selector matches this element?
<div class="star" id="end">Hello</div> (a) #star (b) #end (c) .end (d) span
Answer key
- the viewport meta tag
- 284
- 208
- shows a pop-up message
- purple
- JavaScript
- border
- #ffff00
- { }
- #
- /*
- center
- font-style
- 3
- content
- No
- 2
- bright green
- 20
- :
- 1
- 600px or narrower
- bright green
- yellow
- #main
- 60
- 246
- 12
- flex-end
- color
- 4
- black
- yellow
- lays out the page
- True
- color
- True
- False
- <h1 class="box">
- #end
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids