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.⚖️ What colour is the text of this element?
<h1 class="star" id="main">Hi</h1>
CSS:
#main { color: red; }
.star { color: orange; }
h1 { color: black; } (a) red (b) yellow (c) black (d) orange - 2.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
- 3.📱 Which tag helps phones show a page at the right size? (a) the viewport meta tag (b) the title tag (c) the br tag (d) the hr tag
-
4.⚖️ What colour is the text of this element?
<p class="note" id="hero">Hi</p>
CSS:
.note { color: black; }
p { color: blue; }
#hero { color: green; } (a) white (b) blue (c) black (d) green - 5.✍️ Which sign ends each CSS declaration? (a) ; (b) : (c) , (d) .
- 6.🌈 What is the biggest number one colour can have in rgb()? (a) 100 (b) 255 (c) 1000 (d) 99
-
7.🖌️ Where does the text sit on its line?
h2 {
text-align: left;
background-color: orange;
color: yellow;
font-size: 32px;
} (a) in the middle (b) on the right (c) on the left - 8.🖌️ Which CSS property makes letters bigger? (a) font-family (b) color (c) font-size (d) background-color
-
9.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-style: italic;
color: red;
} -
10.✍️ What value is given to border in this rule?
li {
padding: 8px;
color: red;
border: 2px solid;
margin: 10px;
} (a) italic (b) border (c) 300px (d) 2px solid -
11.🎯 Which CSS selector matches this element?
<h2 class="note" id="end">Hello</h2> (a) #note (b) li (c) .big (d) #end - 12.What does text-align do? (a) makes the text bold (b) centres a heading (c) colours behind the text (d) sets the letter colour
- 13.🎯 Which element does the selector .star style? (a) <span class="star"> (b) <span id="star"> (c) <span class="menu"> (d) <p class="note">
- 14.🌈 In #000038 the blue part is the hex number 38. What is it as a normal number?
-
15.✍️ What value is given to color in this rule?
p {
color: red;
padding: 8px;
} (a) color (b) center (c) red (d) 20px -
16.⚖️ What colour is the text of this element?
<h1 class="box" id="end">Hi</h1>
CSS:
#end { color: green; }
#end { color: red; } (a) green (b) red (c) black (d) purple - 17.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
-
18.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 1024px) {
p {
font-size: 26px;
}
} (a) Yes (b) No - 19.✍️ CSS declarations go inside which brackets? (a) < > (b) { } (c) [ ] (d) ( )
- 20.🖌️ Which CSS property sets the letter colour? (a) font-size (b) text-align (c) background-color (d) color
- 21.What does background-color do? (a) picks the font style (b) sets the letter colour (c) centres a heading (d) colours behind the text
- 22.What does justify-content: space-between do? (a) packs boxes at the end (b) packs boxes at the start (c) puts boxes in the middle (d) equal gaps, none at ends
- 23.💪 Which flexbox property sets space between boxes? (a) gap (b) display: flex (c) align-items (d) flex-direction
-
24.⚖️ What colour is the text of this element?
<p class="star" id="hero">Hi</p>
CSS:
p { color: purple; }
.star { color: black; } (a) purple (b) blue (c) red (d) black - 25.True or false: CSS counts down a timer. (a) True (b) False
- 26.🎨 One CSS file can style how many pages? (a) only one word (b) many pages (c) only one image (d) no pages
- 27.Which of these is padding? (a) a solid or dotted edge (b) the text or picture (c) space inside the border (d) the gap to other boxes
- 28.🔍 Which is the odd one out? (a) changes the page live (b) gives the page structure (c) makes headings and lists (d) makes a form box
- 29.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) blue (c) white (d) red
- 30.🌈 Which hex code is cyan? (a) #00ffff (b) #000000 (c) #ff0000 (d) #0000ff
- 31.🌈 Which hex code is yellow? (a) #ff0000 (b) #ffff00 (c) #00ff00 (d) #ff00ff
- 32.🎯 What kind of selector is #main? (a) a class selector (b) an id selector (c) an element selector
-
33.⚖️ What colour is the text of this element?
<h1 class="menu" id="top">Hi</h1>
CSS:
#top { color: red; }
#top { color: white; } (a) purple (b) black (c) red (d) white - 34.📱 What does a media query check? (a) the page title (b) the time of day (c) the screen width (d) the battery level
-
35.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 270px;
justify-content: flex-start;
}
Inside are 4 boxes, each 50px wide (no margins). - 36.🔍 Which is the odd one out? (a) sets colours and fonts (b) reacts to a button click (c) lays out the page (d) adds space around boxes
- 37.🎯 Which sign starts an id selector? (a) @ (b) & (c) . (d) #
- 38.🧩 Which language changes the page live? (a) JavaScript (b) HTML (c) CSS
-
39.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 190px;
padding: 20px;
border: 1px solid black;
margin: 20px;
} -
40.🖌️ What colour are the letters?
li {
font-size: 24px;
background-color: red;
text-align: left;
color: blue;
} (a) red (b) blue (c) purple
Answer key
- red
- an id selector
- the viewport meta tag
- green
- ;
- 255
- on the left
- font-size
- 2
- 2px solid
- #end
- centres a heading
- <span class="star">
- 56
- red
- red
- an element selector
- No
- { }
- color
- colours behind the text
- equal gaps, none at ends
- gap
- black
- False
- many pages
- space inside the border
- changes the page live
- blue
- #00ffff
- #ffff00
- an id selector
- white
- the screen width
- 70
- reacts to a button click
- #
- JavaScript
- 232
- blue
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids