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 goes between a property and its value? (a) - (b) ; (c) : (d) =
- 2.📦 In the box model, which part is the line round the box? (a) padding (b) border (c) margin (d) content
- 3.What does font-size do? (a) picks the font style (b) makes the text bold (c) makes letters bigger (d) centres a heading
-
4.✍️ What value is given to font-weight in this rule?
.box {
font-weight: bold;
border: 2px solid;
padding: 8px;
margin: 10px;
} (a) font-weight (b) bold (c) 300px (d) 2px solid - 5.🧩 Which language sets colours and fonts? (a) JavaScript (b) HTML (c) CSS
- 6.📦 In the box model, which part is a solid or dotted edge? (a) margin (b) padding (c) border (d) content
- 7.🌈 Which colour is rgb(255, 255, 255)? (a) white (b) yellow (c) blue (d) red
- 8.Which of these does JavaScript do? (a) reacts to a button click (b) makes a form box (c) makes headings and lists (d) lays out the page
-
9.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 50px;
padding: 25px;
border: 3px solid black;
margin: 10px;
} - 10.🌈 Which hex code is blue? (a) #00ffff (b) #0000ff (c) #ffff00 (d) #ffffff
-
11.⚖️ What colour is the text of this element?
<p class="menu" id="logo">Hi</p>
CSS:
p { color: red; }
p { color: purple; } (a) purple (b) white (c) red (d) yellow - 12.💪 Which justify-content value puts boxes in the middle? (a) flex-start (b) flex-end (c) space-between (d) center
- 13.💪 Which flexbox property turns on flexbox? (a) justify-content (b) gap (c) align-items (d) display: flex
- 14.🖌️ Which CSS property sets the letter colour? (a) font-size (b) text-align (c) background-color (d) color
-
15.✍️ Which property is set to bold in this rule?
.note {
font-style: italic;
font-weight: bold;
} (a) font-weight (b) bold (c) border (d) width - 16.🌈 In #0000c8 the blue part is the hex number c8. What is it as a normal number?
-
17.⚖️ What colour is the text of this element?
<p class="box" id="hero">Hi</p>
CSS:
#hero { color: white; }
.box { color: purple; }
p { color: red; } (a) purple (b) blue (c) white (d) red - 18.🧩 Which language makes a form box? (a) HTML (b) CSS (c) JavaScript
- 19.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
-
20.⚖️ What colour is the text of this element?
<p class="menu" id="top">Hi</p>
CSS:
.menu { color: purple; }
.menu { color: red; } (a) yellow (b) blue (c) red (d) purple - 21.📦 In the box model, which part is space outside the border? (a) border (b) content (c) margin (d) padding
-
22.⚖️ What colour is the text of this element?
<h2 class="big" id="intro">Hi</h2>
CSS:
h2 { color: black; }
.big { color: red; } (a) red (b) purple (c) orange (d) black - 23.True or false: .menu is an element selector. (a) True (b) False
- 24.True or false: padding is space inside the border. (a) False (b) True
-
25.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 14px;
}
} (a) Yes (b) No - 26.🌈 In #rrggbb, which colour do the first two digits give? (a) red (b) black (c) blue (d) green
- 27.📱 What does a media query check? (a) the page title (b) the battery level (c) the time of day (d) the screen width
- 28.📱 Responsive design means a page ___. (a) fits every screen (b) has no pictures (c) never changes (d) is only for laptops
- 29.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 4 (b) 3 (c) 2 (d) 6
- 30.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the later one (c) the shorter one (d) the first one
-
31.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 410px;
justify-content: space-between;
}
Inside are 4 boxes, each 80px wide (no margins). - 32.True or false: JavaScript adds space around boxes. (a) True (b) False
- 33.🎯 How many elements on a page should have the same id? (a) any number (b) 2 (c) 5 (d) 1
- 34.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
-
35.🖌️ Where does the text sit on its line?
li {
background-color: red;
font-size: 16px;
text-align: left;
color: orange;
} (a) in the middle (b) on the left (c) on the right - 36.🌈 Which colour is rgb(0, 255, 255)? (a) bright green (b) cyan (c) white (d) red
-
37.🖌️ What colour is behind the letters?
h1 {
font-size: 40px;
background-color: yellow;
text-align: left;
color: white;
} (a) yellow (b) white (c) blue -
38.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 220px;
justify-content: flex-start;
}
Inside are 3 boxes, each 50px wide (no margins). -
39.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 160px;
padding: 30px;
border: 4px solid black;
margin: 15px;
} -
40.✍️ How many declarations (property: value pairs) are in this rule?
li {
text-align: center;
}
Answer key
- :
- border
- makes letters bigger
- bold
- CSS
- border
- white
- reacts to a button click
- 126
- #0000ff
- purple
- center
- display: flex
- color
- font-weight
- 200
- white
- HTML
- an element selector
- red
- margin
- red
- False
- True
- No
- red
- the screen width
- fits every screen
- 3
- the later one
- 30
- False
- 1
- an id selector
- on the left
- cyan
- yellow
- 70
- 258
- 1
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids