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.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 768px) {
p {
font-size: 28px;
}
} -
2.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 70px;
padding: 20px;
border: 5px solid black;
margin: 0px;
} - 3.True or false: p is an id selector. (a) False (b) True
- 4.🧩 Which language gives the page structure? (a) CSS (b) JavaScript (c) HTML
- 5.True or false: the border is a solid or dotted edge. (a) True (b) False
- 6.✍️ How does a CSS comment start? (a) /* (b) # (c) // (d) <!--
- 7.🧩 Which language shows a pop-up message? (a) HTML (b) CSS (c) JavaScript
- 8.🌈 Hex digits go 0 to 9, then A to which letter? (a) J (b) F (c) G (d) Z
-
9.⚖️ What colour is the text of this element?
<h1 class="red" id="logo">Hi</h1>
CSS:
h1 { color: blue; }
h1 { color: purple; } (a) blue (b) purple (c) orange (d) yellow - 10.🌈 Which hex code is black? (a) #ffff00 (b) #000000 (c) #ff0000 (d) #ff00ff
-
11.🖌️ What colour are the letters?
h1 {
background-color: red;
color: blue;
text-align: left;
font-size: 32px;
} (a) blue (b) red (c) green -
12.🎯 Which CSS selector matches this element?
<h1 class="box" id="logo">Hello</h1> (a) #box (b) .star (c) .logo (d) h1 - 13.🎨 Which tag connects an outside CSS file? (a) <a> (b) <img> (c) <link> (d) <css>
-
14.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 20px;
}
} (a) Yes (b) No - 15.🌈 Which colour is rgb(255, 0, 255)? (a) blue (b) red (c) white (d) magenta
- 16.✍️ Which sign ends each CSS declaration? (a) : (b) . (c) , (d) ;
- 17.What does justify-content: flex-start do? (a) puts boxes in the middle (b) equal gaps, none at ends (c) packs boxes at the end (d) packs boxes at the start
- 18.What does font-family do? (a) colours behind the text (b) picks the font style (c) sets the letter colour (d) makes letters bigger
-
19.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 1024px) {
p {
font-size: 26px;
}
} - 20.💪 Which flexbox property sets space between boxes? (a) display: flex (b) flex-direction (c) justify-content (d) gap
- 21.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 2 (b) 6 (c) 4 (d) 3
-
22.🎯 Which CSS selector matches this element?
<h1 class="note" id="top">Hello</h1> (a) .note (b) .big (c) #intro (d) #note -
23.🖌️ What colour are the letters?
p {
text-align: right;
font-size: 36px;
color: black;
background-color: blue;
} (a) orange (b) blue (c) black - 24.🧩 Which language sets colours and fonts? (a) JavaScript (b) HTML (c) CSS
- 25.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
- 26.🔍 Which is the odd one out? (a) puts a picture on a page (b) reacts to a button click (c) counts down a timer (d) changes the page live
-
27.✍️ How many declarations (property: value pairs) are in this rule?
body {
color: red;
width: 300px;
} - 28.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
-
29.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} (a) No (b) Yes - 30.What does justify-content: flex-end 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
-
31.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 190px;
padding: 5px;
border: 3px solid black;
margin: 20px;
} - 32.True or false: li is an element selector. (a) False (b) True
- 33.What does color do? (a) picks the font style (b) makes letters bigger (c) sets the letter colour (d) centres a heading
- 34.💪 Which justify-content value equal gaps, none at ends? (a) center (b) space-between (c) flex-end (d) flex-start
- 35.⚖️ 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
- 36.True or false: JavaScript gives the page structure. (a) True (b) False
-
37.🖌️ Where does the text sit on its line?
p {
color: orange;
text-align: center;
font-size: 12px;
background-color: black;
} (a) on the right (b) in the middle (c) on the left -
38.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 6px;
}
} (a) Yes (b) No - 39.🎯 Can many elements share the same class? (a) Yes (b) No
- 40.🌈 In #000042 the blue part is the hex number 42. What is it as a normal number?
Answer key
- 28
- 120
- False
- HTML
- True
- /*
- JavaScript
- F
- purple
- #000000
- blue
- h1
- <link>
- No
- magenta
- ;
- packs boxes at the start
- picks the font style
- 20
- gap
- 3
- .note
- black
- CSS
- an element selector
- puts a picture on a page
- 2
- an id selector
- Yes
- packs boxes at the end
- 206
- True
- sets the letter colour
- space-between
- the later one
- False
- in the middle
- No
- Yes
- 66
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids