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.🌈 In #00d400 the green part is the hex number d4. What is it as a normal number?
-
2.✍️ What value is given to font-size in this rule?
body {
font-size: 20px;
font-style: italic;
background-color: yellow;
} (a) font-size (b) yellow (c) 20px (d) center -
3.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 22px;
}
} - 4.🌈 Which hex code is white? (a) #00ffff (b) #00ff00 (c) #ff00ff (d) #ffffff
-
5.⚖️ What colour is the text of this element?
<h1 class="red" id="end">Hi</h1>
CSS:
#end { color: purple; }
.red { color: black; } (a) blue (b) orange (c) black (d) purple -
6.🖌️ How big is the text, in px?
p {
text-align: right;
color: green;
background-color: red;
font-size: 20px;
} - 7.What does font-weight do? (a) makes the text bold (b) colours behind the text (c) picks the font style (d) makes letters bigger
- 8.🎨 Which tag connects an outside CSS file? (a) <link> (b) <img> (c) <a> (d) <css>
- 9.✍️ In color: blue; which part is the property? (a) ; (b) : (c) color (d) blue
-
10.✍️ What is the selector in this CSS rule?
.note {
font-style: italic;
color: red;
margin: 10px;
} (a) .note (b) red (c) #top (d) font-style - 11.💪 Which justify-content value puts boxes in the middle? (a) flex-start (b) center (c) space-between (d) flex-end
-
12.⚖️ What colour is the text of this element?
<h2 class="star" id="main">Hi</h2>
CSS:
h2 { color: white; }
h2 { color: yellow; } (a) white (b) black (c) blue (d) yellow - 13.🎯 How many elements on a page should have the same id? (a) 5 (b) 2 (c) 1 (d) any number
- 14.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
-
15.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 80px;
padding: 15px;
border: 4px solid black;
margin: 15px;
} - 16.📦 In the box model, which part is the gap round content? (a) padding (b) content (c) margin (d) border
-
17.✍️ What is the selector in this CSS rule?
h1 {
font-size: 20px;
font-weight: bold;
font-style: italic;
padding: 8px;
} (a) p (b) font-size (c) bold (d) h1 - 18.🎯 Which element does the selector span style? (a) <p> (b) <span class="menu"> (c) <h1 class="menu"> (d) <h2 id="hero">
- 19.📦 In the box model, which part is a solid or dotted edge? (a) content (b) margin (c) border (d) padding
- 20.✍️ In color: blue; which part is the value? (a) color (b) ; (c) blue (d) :
- 21.Which of these is padding? (a) the line round the box (b) the gap to other boxes (c) space outside the border (d) space inside the border
-
22.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
margin: 10px;
} - 23.🌈 Which colour is rgb(255, 255, 255)? (a) red (b) yellow (c) white (d) black
-
24.🎯 Which CSS selector matches this element?
<li class="star" id="intro">Hello</li> (a) #main (b) .intro (c) div (d) .star - 25.What does font-family do? (a) colours behind the text (b) makes letters bigger (c) picks the font style (d) centres a heading
- 26.💪 Which flexbox property sets space between boxes? (a) display: flex (b) flex-direction (c) align-items (d) gap
- 27.True or false: JavaScript lays out the page. (a) True (b) False
-
28.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 14px;
}
} (a) No (b) Yes - 29.🌈 Which colour is #ff00ff? (a) bright green (b) white (c) yellow (d) magenta
- 30.🎯 Which element does the selector .big style? (a) <p class="big"> (b) <p id="big"> (c) <h1 class="box"> (d) <p class="red">
- 31.✍️ CSS declarations go inside which brackets? (a) < > (b) { } (c) [ ] (d) ( )
-
32.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 24px;
}
} -
33.🎯 Which CSS selector matches this element?
<p class="big" id="top">Hello</p> (a) #big (b) #intro (c) #top (d) .top -
34.⚖️ What colour is the text of this element?
<h1 class="star" id="logo">Hi</h1>
CSS:
#logo { color: green; }
#logo { color: black; } (a) green (b) yellow (c) black (d) red - 35.💪 Which justify-content value equal gaps, none at ends? (a) flex-end (b) flex-start (c) space-between (d) center
-
36.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 230px;
padding: 30px;
border: 2px solid black;
margin: 20px;
} -
37.🎯 Which CSS selector matches this element?
<h2 class="box" id="top">Hello</h2> (a) #intro (b) li (c) .star (d) .box - 38.🌈 Which colour is rgb(255, 0, 255)? (a) blue (b) cyan (c) magenta (d) bright green
-
39.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 1024px) {
p {
font-size: 16px;
}
} -
40.⚖️ What colour is the text of this element?
<p class="red" id="end">Hi</p>
CSS:
.red { color: blue; }
.red { color: black; } (a) black (b) blue (c) red (d) orange
Answer key
- 212
- 20px
- 22
- #ffffff
- purple
- 20
- makes the text bold
- <link>
- color
- .note
- center
- yellow
- 1
- an element selector
- 148
- padding
- h1
- <span class="menu">
- border
- blue
- space inside the border
- 1
- white
- .star
- picks the font style
- gap
- False
- Yes
- magenta
- <p class="big">
- { }
- 16
- #top
- black
- space-between
- 294
- .box
- magenta
- 16
- black
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids