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 are the letters?
p {
background-color: green;
text-align: right;
font-size: 28px;
color: purple;
} (a) green (b) purple (c) yellow -
2.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 18px;
}
} - 3.🎨 Which tag connects an outside CSS file? (a) <a> (b) <img> (c) <css> (d) <link>
-
4.✍️ What is the selector in this CSS rule?
#top {
border: 2px solid;
font-weight: bold;
} (a) border (b) bold (c) #top (d) li -
5.🎯 Which CSS selector matches this element?
<h1 class="star" id="top">Hello</h1> (a) .menu (b) #star (c) #intro (d) h1 - 6.🎯 What kind of selector is h1? (a) a class selector (b) an element selector (c) an id selector
-
7.📱 The screen is 700px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 12px;
}
} (a) No (b) Yes - 8.🌈 Which colour is #ff00ff? (a) magenta (b) red (c) blue (d) black
- 9.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) white (c) red (d) blue
- 10.🧩 Which language sets colours and fonts? (a) CSS (b) JavaScript (c) HTML
-
11.⚖️ What colour is the text of this element?
<h2 class="star" id="intro">Hi</h2>
CSS:
#intro { color: white; }
#intro { color: red; } (a) red (b) purple (c) blue (d) white -
12.🖌️ What colour are the letters?
p {
text-align: center;
background-color: purple;
color: green;
font-size: 24px;
} (a) green (b) purple (c) blue -
13.⚖️ What colour is the text of this element?
<p class="note" id="top">Hi</p>
CSS:
p { color: red; }
p { color: white; } (a) green (b) orange (c) white (d) red -
14.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 210px;
justify-content: space-between;
}
Inside are 2 boxes, each 100px wide (no margins). - 15.🧩 Which language reacts to a button click? (a) CSS (b) JavaScript (c) HTML
-
16.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 460px;
justify-content: space-between;
}
Inside are 4 boxes, each 100px wide (no margins). -
17.⚖️ What colour is the text of this element?
<p class="box" id="end">Hi</p>
CSS:
#end { color: blue; }
p { color: green; }
.box { color: red; } (a) yellow (b) blue (c) green (d) red - 18.✍️ Which sign ends each CSS declaration? (a) , (b) . (c) ; (d) :
-
19.✍️ What value is given to width in this rule?
p {
width: 300px;
font-size: 20px;
border: 2px solid;
} (a) width (b) 300px (c) red (d) italic - 20.🎨 Which attribute adds CSS inside one tag? (a) href (b) src (c) style (d) alt
- 21.🌈 Hex digits go 0 to 9, then A to which letter? (a) G (b) Z (c) F (d) J
-
22.✍️ Which property is set to yellow in this rule?
h1 {
font-size: 20px;
width: 300px;
background-color: yellow;
} (a) padding (b) background-color (c) yellow (d) margin -
23.⚖️ What colour is the text of this element?
<p class="box" id="end">Hi</p>
CSS:
#end { color: orange; }
#end { color: white; } (a) red (b) orange (c) yellow (d) white -
24.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 270px;
justify-content: space-between;
}
Inside are 2 boxes, each 100px wide (no margins). - 25.⚖️ 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
-
26.🖌️ What colour are the letters?
p {
background-color: purple;
font-size: 40px;
text-align: center;
color: blue;
} (a) red (b) blue (c) purple - 27.True or false: #end is an id selector. (a) False (b) True
- 28.📱 What does a media query check? (a) the page title (b) the screen width (c) the time of day (d) the battery level
- 29.📦 In the box model, which part is the gap to other boxes? (a) margin (b) border (c) padding (d) content
-
30.✍️ What is the selector in this CSS rule?
li {
text-align: center;
width: 300px;
color: red;
margin: 10px;
} (a) text-align (b) li (c) body (d) 300px -
31.🎯 Which CSS selector matches this element?
<li class="note" id="top">Hello</li> (a) .big (b) .top (c) .note (d) div - 32.🎯 What kind of selector is #hero? (a) an id selector (b) a class selector (c) an element selector
- 33.✍️ How does a CSS comment start? (a) /* (b) <!-- (c) // (d) #
- 34.💪 Which flexbox property sets space between boxes? (a) flex-direction (b) justify-content (c) gap (d) align-items
- 35.🧩 Which language lays out the page? (a) HTML (b) JavaScript (c) CSS
- 36.🌈 In #006300 the green part is the hex number 63. What is it as a normal number?
-
37.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 260px;
padding: 10px;
border: 4px solid black;
margin: 10px;
} - 38.Which of these does JavaScript do? (a) sets colours and fonts (b) gives the page structure (c) checks a quiz answer (d) puts a picture on a page
-
39.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 480px) {
p {
font-size: 20px;
}
} - 40.🧩 Which language adds space around boxes? (a) HTML (b) JavaScript (c) CSS
Answer key
- purple
- 12
- <link>
- #top
- h1
- an element selector
- Yes
- magenta
- blue
- CSS
- red
- green
- white
- 10
- JavaScript
- 20
- blue
- ;
- 300px
- style
- F
- background-color
- white
- 70
- the later one
- blue
- True
- the screen width
- margin
- li
- .note
- an id selector
- /*
- gap
- CSS
- 99
- 308
- checks a quiz answer
- 20
- CSS
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids