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 does a CSS comment start? (a) /* (b) # (c) // (d) <!--
- 2.🎯 Which element does the selector #main style? (a) <div id="main"> (b) <div id="logo"> (c) <span class="red"> (d) <div class="main">
-
3.✍️ What is the selector in this CSS rule?
.box {
padding: 8px;
font-style: italic;
margin: 10px;
font-weight: bold;
} (a) .box (b) h2 (c) padding (d) italic -
4.⚖️ What colour is the text of this element?
<p class="red" id="end">Hi</p>
CSS:
#end { color: black; }
p { color: orange; } (a) orange (b) black (c) red (d) green - 5.🧩 Which language puts a picture on a page? (a) CSS (b) JavaScript (c) HTML
-
6.✍️ What is the selector in this CSS rule?
p {
font-weight: bold;
width: 300px;
margin: 10px;
} (a) 300px (b) font-weight (c) .note (d) p - 7.🎯 Which element does the selector p style? (a) <h1> (b) <li id="intro"> (c) <p class="menu"> (d) <h2 class="menu">
- 8.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
-
9.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 1024px) {
p {
font-size: 18px;
}
} - 10.🌈 Hex digits go 0 to 9, then A to which letter? (a) J (b) Z (c) G (d) F
- 11.🌈 Which hex code is bright green? (a) #00ff00 (b) #00ffff (c) #ffff00 (d) #000000
-
12.✍️ What is the selector in this CSS rule?
li {
width: 300px;
background-color: yellow;
} (a) body (b) width (c) yellow (d) li - 13.✍️ Which sign goes between a property and its value? (a) - (b) ; (c) = (d) :
- 14.💪 Which justify-content value packs boxes at the end? (a) space-between (b) flex-start (c) flex-end (d) center
- 15.What does font-size do? (a) centres a heading (b) makes letters bigger (c) colours behind the text (d) sets the letter colour
- 16.🌈 Which colour is #ff0000? (a) cyan (b) bright green (c) blue (d) red
-
17.✍️ What is the selector in this CSS rule?
h1 {
color: red;
margin: 10px;
width: 300px;
font-style: italic;
} (a) color (b) h1 (c) 10px (d) p - 18.What does background-color do? (a) makes letters bigger (b) sets the letter colour (c) centres a heading (d) colours behind the text
- 19.🌈 Which colour is rgb(255, 0, 255)? (a) bright green (b) black (c) white (d) magenta
- 20.💪 Which flexbox property picks row or column? (a) justify-content (b) flex-direction (c) align-items (d) display: flex
- 21.📱 Responsive design means a page ___. (a) never changes (b) fits every screen (c) has no pictures (d) is only for laptops
- 22.What does text-align do? (a) centres a heading (b) colours behind the text (c) picks the font style (d) makes letters bigger
-
23.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 32px;
}
} (a) Yes (b) No - 24.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the shorter one (c) the later one (d) the first one
-
25.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
font-style: italic;
} - 26.🌈 In #070000 the red part is the hex number 07. What is it as a normal number?
- 27.🌈 Which colour of light is strongest in rgb(21, 171, 5)? (a) red (b) blue (c) green
-
28.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 18px;
}
} - 29.🖌️ Which CSS property makes letters bigger? (a) color (b) background-color (c) font-weight (d) font-size
-
30.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 310px;
justify-content: flex-end;
}
Inside are 3 boxes, each 100px wide (no margins). -
31.⚖️ What colour is the text of this element?
<p class="star" id="hero">Hi</p>
CSS:
.star { color: red; }
#hero { color: yellow; } (a) red (b) yellow (c) purple (d) blue - 32.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) red (c) green (d) white
-
33.✍️ What is the selector in this CSS rule?
body {
font-style: italic;
font-size: 20px;
} (a) font-style (b) .box (c) body (d) 20px -
34.🖌️ What colour are the letters?
p {
color: green;
background-color: black;
text-align: right;
font-size: 16px;
} (a) black (b) white (c) green -
35.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 160px;
padding: 25px;
border: 2px solid black;
margin: 5px;
} -
36.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 14px;
}
} - 37.✍️ Which sign ends each CSS declaration? (a) . (b) : (c) ; (d) ,
-
38.✍️ What value is given to width in this rule?
li {
font-style: italic;
font-weight: bold;
width: 300px;
} (a) italic (b) width (c) red (d) 300px -
39.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 22px;
}
} -
40.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 80px;
padding: 10px;
border: 3px solid black;
margin: 5px;
}
Answer key
- /*
- <div id="main">
- .box
- black
- HTML
- p
- <p class="menu">
- an element selector
- 18
- F
- #00ff00
- li
- :
- flex-end
- makes letters bigger
- red
- h1
- colours behind the text
- magenta
- flex-direction
- fits every screen
- centres a heading
- Yes
- the later one
- 1
- 7
- green
- 18
- font-size
- 10
- yellow
- blue
- body
- green
- 224
- 14
- ;
- 300px
- 24
- 116
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids