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 #rrggbb, which colour do the first two digits give? (a) black (b) green (c) blue (d) red
-
2.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 160px;
justify-content: flex-start;
}
Inside are 2 boxes, each 60px wide (no margins). - 3.True or false: p is an element selector. (a) False (b) True
- 4.🔍 Which is the odd one out? (a) makes headings and lists (b) lays out the page (c) sets colours and fonts (d) rounds box corners
- 5.🎨 Which tag connects an outside CSS file? (a) <a> (b) <img> (c) <css> (d) <link>
- 6.🎯 What kind of selector is .note? (a) an element selector (b) an id selector (c) a class selector
-
7.🖌️ Where does the text sit on its line?
p {
text-align: right;
background-color: yellow;
color: blue;
font-size: 12px;
} (a) in the middle (b) on the left (c) on the right - 8.🎯 Which sign starts an id selector? (a) @ (b) . (c) & (d) #
- 9.🌈 Which colour is #00ff00? (a) cyan (b) white (c) bright green (d) red
-
10.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 140px;
padding: 20px;
border: 1px solid black;
margin: 15px;
} - 11.🎨 One CSS file can style how many pages? (a) many pages (b) only one image (c) only one word (d) no pages
-
12.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} -
13.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 140px;
padding: 5px;
border: 1px solid black;
margin: 15px;
} - 14.What does background-color do? (a) centres a heading (b) colours behind the text (c) sets the letter colour (d) picks the font style
-
15.✍️ What is the selector in this CSS rule?
.note {
padding: 8px;
text-align: center;
color: red;
font-size: 20px;
} (a) padding (b) center (c) .note (d) #top -
16.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 220px;
justify-content: space-between;
}
Inside are 2 boxes, each 100px wide (no margins). -
17.🖌️ How big is the text, in px?
h2 {
color: black;
text-align: right;
background-color: blue;
font-size: 40px;
} - 18.🌈 Which colour of light is strongest in rgb(126, 100, 200)? (a) blue (b) red (c) green
- 19.✍️ Which sign ends each CSS declaration? (a) , (b) : (c) . (d) ;
- 20.🎯 Which element does the selector div style? (a) <div class="menu"> (b) <span> (c) <h1 id="logo"> (d) <p class="menu">
- 21.🎯 Which element does the selector .note style? (a) <li id="note"> (b) <li class="note"> (c) <div class="red"> (d) <li class="big">
-
22.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 16px;
}
} (a) Yes (b) No -
23.🖌️ What colour are the letters?
li {
font-size: 12px;
text-align: left;
color: yellow;
background-color: purple;
} (a) purple (b) yellow (c) black - 24.📱 Which tag helps phones show a page at the right size? (a) the br tag (b) the hr tag (c) the title tag (d) the viewport meta tag
-
25.🖌️ What colour is behind the letters?
li {
background-color: black;
font-size: 12px;
color: yellow;
text-align: center;
} (a) black (b) white (c) yellow - 26.🌈 Which hex code is bright green? (a) #0000ff (b) #ffffff (c) #ff0000 (d) #00ff00
- 27.🎯 Which element does the selector #intro style? (a) <div class="big"> (b) <li id="main"> (c) <li class="intro"> (d) <li id="intro">
-
28.✍️ What is the selector in this CSS rule?
#top {
border: 2px solid;
text-align: center;
background-color: yellow;
} (a) center (b) li (c) border (d) #top -
29.✍️ Which property is set to 20px in this rule?
li {
font-weight: bold;
color: red;
font-size: 20px;
} (a) background-color (b) 20px (c) font-size (d) text-align - 30.Which of these does JavaScript do? (a) checks a quiz answer (b) sets colours and fonts (c) makes a form box (d) adds space around boxes
-
31.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 50px;
padding: 5px;
border: 3px solid black;
margin: 0px;
} - 32.What does font-size do? (a) makes letters bigger (b) makes the text bold (c) colours behind the text (d) centres a heading
- 33.🔍 Which is the odd one out? (a) counts down a timer (b) sets colours and fonts (c) changes the page live (d) reacts to a button click
-
34.⚖️ What colour is the text of this element?
<h1 class="note" id="logo">Hi</h1>
CSS:
#logo { color: blue; }
#logo { color: black; } (a) blue (b) red (c) white (d) black - 35.✍️ CSS declarations go inside which brackets? (a) < > (b) [ ] (c) { } (d) ( )
- 36.🎯 What kind of selector is .menu? (a) an id selector (b) an element selector (c) a class selector
-
37.🖌️ What colour is behind the letters?
h2 {
background-color: purple;
text-align: center;
font-size: 36px;
color: yellow;
} (a) purple (b) yellow (c) black -
38.✍️ What is the selector in this CSS rule?
.box {
margin: 10px;
padding: 8px;
} (a) h2 (b) .box (c) margin (d) 8px -
39.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} - 40.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
Answer key
- red
- 40
- True
- makes headings and lists
- <link>
- a class selector
- on the right
- #
- bright green
- 182
- many pages
- 20
- 182
- colours behind the text
- .note
- 20
- 40
- blue
- ;
- <div class="menu">
- <li class="note">
- Yes
- yellow
- the viewport meta tag
- black
- #00ff00
- <li id="intro">
- #top
- font-size
- checks a quiz answer
- 66
- makes letters bigger
- sets colours and fonts
- black
- { }
- a class selector
- purple
- .box
- 18
- an element selector
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids