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 hex code is black? (a) #ffffff (b) #00ff00 (c) #000000 (d) #0000ff
-
2.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 60px;
padding: 30px;
border: 1px solid black;
margin: 20px;
} - 3.📦 In the box model, which part is space inside the border? (a) content (b) padding (c) border (d) margin
-
4.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 480px) {
p {
font-size: 14px;
}
} (a) No (b) Yes -
5.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 190px;
justify-content: space-between;
}
Inside are 3 boxes, each 50px wide (no margins). -
6.🖌️ What colour is behind the letters?
h2 {
font-size: 12px;
background-color: green;
text-align: right;
color: yellow;
} (a) purple (b) green (c) yellow - 7.🌈 Which colour is #000000? (a) black (b) white (c) yellow (d) cyan
- 8.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) green (c) red (d) white
-
9.🖌️ Where does the text sit on its line?
p {
text-align: left;
font-size: 28px;
background-color: white;
color: yellow;
} (a) on the left (b) on the right (c) in the middle - 10.⚖️ 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
- 11.What does font-weight do? (a) makes letters bigger (b) makes the text bold (c) picks the font style (d) centres a heading
-
12.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 520px;
justify-content: center;
}
Inside are 4 boxes, each 100px wide (no margins). - 13.📦 In the box model, which part is the line round the box? (a) content (b) margin (c) border (d) padding
-
14.📱 The screen is 1100px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 18px;
}
} (a) No (b) Yes - 15.What does color do? (a) picks the font style (b) centres a heading (c) makes the text bold (d) sets the letter colour
- 16.💪 Which justify-content value packs boxes at the start? (a) flex-start (b) center (c) flex-end (d) space-between
- 17.🖌️ Which CSS property picks the font style? (a) background-color (b) font-size (c) font-family (d) font-weight
- 18.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) turned off (c) 600px or wider (d) 600px or narrower
- 19.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
- 20.🎯 What kind of selector is p? (a) a class selector (b) an id selector (c) an element selector
-
21.✍️ What is the selector in this CSS rule?
.note {
padding: 8px;
font-style: italic;
} (a) #top (b) .note (c) padding (d) italic - 22.✍️ In color: blue; which part is the value? (a) : (b) blue (c) color (d) ;
-
23.✍️ What is the selector in this CSS rule?
body {
background-color: yellow;
font-style: italic;
} (a) .box (b) body (c) italic (d) background-color - 24.🌈 What is the biggest number one colour can have in rgb()? (a) 255 (b) 99 (c) 100 (d) 1000
-
25.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 90px;
padding: 30px;
border: 3px solid black;
margin: 0px;
} -
26.🎯 Which CSS selector matches this element?
<div class="note" id="end">Hello</div> (a) .end (b) #end (c) span (d) .big - 27.Which of these is the border? (a) a solid or dotted edge (b) space outside the border (c) the gap to other boxes (d) the text or picture
-
28.🎯 Which CSS selector matches this element?
<div class="box" id="end">Hello</div> (a) #hero (b) .star (c) div (d) span - 29.🎯 Which sign starts a class selector? (a) # (b) @ (c) & (d) .
- 30.What does background-color do? (a) colours behind the text (b) centres a heading (c) sets the letter colour (d) makes the text bold
-
31.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
background-color: yellow;
color: red;
} - 32.🎯 Which element does the selector #main style? (a) <div class="main"> (b) <span class="note"> (c) <div id="main"> (d) <div id="logo">
-
33.✍️ Which property is set to red in this rule?
h1 {
font-weight: bold;
background-color: yellow;
color: red;
padding: 8px;
} (a) font-size (b) text-align (c) color (d) red - 34.🔍 Which is the odd one out? (a) sets colours and fonts (b) gives the page structure (c) changes the text size (d) adds space around boxes
-
35.🖌️ What colour is behind the letters?
p {
text-align: right;
font-size: 12px;
color: green;
background-color: black;
} (a) green (b) red (c) black - 36.🖌️ Which CSS property makes the text bold? (a) font-weight (b) font-size (c) font-family (d) background-color
- 37.True or false: JavaScript makes a form box. (a) True (b) False
-
38.🎯 Which CSS selector matches this element?
<span class="note" id="main">Hello</span> (a) .main (b) #main (c) .big (d) #note -
39.🖌️ What colour are the letters?
h1 {
font-size: 36px;
background-color: yellow;
text-align: center;
color: blue;
} (a) purple (b) yellow (c) blue - 40.Which of these does JavaScript do? (a) makes a link (b) makes a form box (c) reacts to a button click (d) rounds box corners
Answer key
- #000000
- 162
- padding
- Yes
- 20
- green
- black
- blue
- on the left
- the later one
- makes the text bold
- 60
- border
- Yes
- sets the letter colour
- flex-start
- font-family
- 600px or narrower
- an id selector
- an element selector
- .note
- blue
- body
- 255
- 156
- #end
- a solid or dotted edge
- div
- .
- colours behind the text
- 2
- <div id="main">
- color
- gives the page structure
- black
- font-weight
- False
- #main
- blue
- reacts to a button click
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids