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 empty space (px) is before the first box?
.row {
display: flex;
width: 230px;
justify-content: flex-end;
}
Inside are 2 boxes, each 100px wide (no margins). - 2.Which of these is padding? (a) space inside the border (b) a solid or dotted edge (c) the gap to other boxes (d) space outside the border
-
3.✍️ Which property is set to 20px in this rule?
.box {
font-size: 20px;
text-align: center;
} (a) text-align (b) 20px (c) background-color (d) font-size - 4.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the shorter one (c) the later one (d) neither
-
5.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 270px;
padding: 15px;
border: 4px solid black;
margin: 5px;
} - 6.✍️ Which sign goes between a property and its value? (a) : (b) - (c) ; (d) =
- 7.Which of these does CSS do? (a) shows a pop-up message (b) counts down a timer (c) reacts to a button click (d) sets colours and fonts
- 8.🌈 In #000063 the blue part is the hex number 63. What is it as a normal number?
-
9.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 290px;
padding: 10px;
border: 1px solid black;
margin: 20px;
} - 10.🎯 Can many elements share the same class? (a) Yes (b) No
- 11.🖌️ Which CSS property colours behind the text? (a) color (b) background-color (c) font-size (d) font-weight
-
12.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 500px;
justify-content: center;
}
Inside are 4 boxes, each 100px wide (no margins). -
13.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 170px;
padding: 30px;
border: 5px solid black;
margin: 0px;
} - 14.🎨 Which attribute adds CSS inside one tag? (a) src (b) style (c) alt (d) href
- 15.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the br tag (c) the viewport meta tag (d) the hr tag
- 16.✍️ CSS declarations go inside which brackets? (a) ( ) (b) < > (c) { } (d) [ ]
-
17.✍️ How many declarations (property: value pairs) are in this rule?
body {
border: 2px solid;
font-style: italic;
margin: 10px;
} - 18.True or false: .card is an id selector. (a) True (b) False
- 19.💪 Which flexbox property sets space between boxes? (a) display: flex (b) justify-content (c) flex-direction (d) gap
-
20.✍️ How many declarations (property: value pairs) are in this rule?
#top {
color: red;
} - 21.🔍 Which is the odd one out? (a) rounds box corners (b) makes a form box (c) puts a picture on a page (d) makes headings and lists
-
22.✍️ Which property is set to 10px in this rule?
body {
margin: 10px;
text-align: center;
padding: 8px;
font-style: italic;
} (a) font-weight (b) margin (c) padding (d) 10px -
23.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 16px;
}
} - 24.What does text-align do? (a) sets the letter colour (b) picks the font style (c) colours behind the text (d) centres a heading
-
25.✍️ Which property is set to 300px in this rule?
.box {
color: red;
margin: 10px;
width: 300px;
padding: 8px;
} (a) font-style (b) 300px (c) color (d) width -
26.✍️ What value is given to text-align in this rule?
h2 {
text-align: center;
font-style: italic;
} (a) text-align (b) yellow (c) center (d) 10px -
27.⚖️ What colour is the text of this element?
<p class="star" id="hero">Hi</p>
CSS:
p { color: green; }
.star { color: black; } (a) black (b) green (c) white (d) orange - 28.🌈 Which colour is rgb(0, 0, 255)? (a) red (b) blue (c) white (d) yellow
- 29.🖌️ Which CSS property picks the font style? (a) background-color (b) font-family (c) text-align (d) font-weight
-
30.⚖️ What colour is the text of this element?
<h2 class="note" id="hero">Hi</h2>
CSS:
h2 { color: blue; }
h2 { color: purple; } (a) blue (b) green (c) purple (d) black -
31.🖌️ Where does the text sit on its line?
li {
color: green;
background-color: blue;
font-size: 16px;
text-align: left;
} (a) on the left (b) on the right (c) in the middle - 32.🎯 Which element does the selector #top style? (a) <p id="intro"> (b) <p id="top"> (c) <h1 class="big"> (d) <p class="top">
-
33.🖌️ How big is the text, in px?
li {
font-size: 20px;
background-color: blue;
color: white;
text-align: left;
} - 34.🌈 Which colour is rgb(0, 0, 0)? (a) blue (b) cyan (c) red (d) black
- 35.🌈 In #008900 the green part is the hex number 89. What is it as a normal number?
- 36.What does font-size do? (a) centres a heading (b) colours behind the text (c) makes the text bold (d) makes letters bigger
- 37.🎨 What does CSS stand for? (a) Cascading Style Sheets (b) Creative Sheet System (c) Computer Style Sheets (d) Colourful Site Styles
- 38.⚖️ Which selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
-
39.📱 The screen is 375px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 22px;
}
} (a) Yes (b) No -
40.🎯 Which CSS selector matches this element?
<li class="big" id="intro">Hello</li> (a) .intro (b) li (c) div (d) #big
Answer key
- 30
- space inside the border
- font-size
- the later one
- 318
- :
- sets colours and fonts
- 99
- 312
- Yes
- background-color
- 50
- 240
- style
- the viewport meta tag
- { }
- 3
- False
- gap
- 1
- rounds box corners
- margin
- 16
- centres a heading
- width
- center
- black
- blue
- font-family
- purple
- on the left
- <p id="top">
- 20
- black
- 137
- makes letters bigger
- Cascading Style Sheets
- an id selector
- No
- li
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids