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="red" id="hero">Hi</h1>
CSS:
#hero { color: red; }
.red { color: blue; }
h1 { color: white; } (a) blue (b) orange (c) red (d) white -
2.✍️ What is the selector in this CSS rule?
p {
padding: 8px;
font-weight: bold;
background-color: yellow;
} (a) p (b) .note (c) bold (d) padding -
3.⚖️ What colour is the text of this element?
<p class="box" id="main">Hi</p>
CSS:
p { color: black; }
.box { color: blue; } (a) orange (b) blue (c) black (d) red - 4.🧩 Which language changes the page live? (a) HTML (b) JavaScript (c) CSS
-
5.🎯 Which CSS selector matches this element?
<p class="box" id="top">Hello</p> (a) .top (b) #intro (c) h1 (d) .box - 6.What does justify-content: space-between do? (a) packs boxes at the start (b) puts boxes in the middle (c) packs boxes at the end (d) equal gaps, none at ends
- 7.True or false: JavaScript reacts to a button click. (a) True (b) False
- 8.True or false: img is an id selector. (a) True (b) False
-
9.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 14px;
}
} - 10.Which of these is the content? (a) the gap to other boxes (b) the text or picture (c) the line round the box (d) space inside the border
-
11.⚖️ What colour is the text of this element?
<h1 class="big" id="end">Hi</h1>
CSS:
h1 { color: blue; }
h1 { color: red; } (a) white (b) blue (c) black (d) red - 12.True or false: .card is an id selector. (a) True (b) False
- 13.🌈 Which colour of light is strongest in rgb(228, 70, 128)? (a) blue (b) green (c) red
-
14.🖌️ Where does the text sit on its line?
h1 {
font-size: 12px;
color: red;
background-color: purple;
text-align: center;
} (a) on the left (b) in the middle (c) on the right - 15.🖌️ Which CSS property picks the font style? (a) text-align (b) font-size (c) font-weight (d) font-family
-
16.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 140px;
justify-content: flex-end;
}
Inside are 2 boxes, each 50px wide (no margins). -
17.⚖️ What colour is the text of this element?
<p class="star" id="hero">Hi</p>
CSS:
.star { color: red; }
.star { color: yellow; } (a) red (b) black (c) yellow (d) white - 18.What does justify-content: flex-start do? (a) puts boxes in the middle (b) packs boxes at the start (c) equal gaps, none at ends (d) packs boxes at the end
- 19.🎯 What kind of selector is .menu? (a) a class selector (b) an id selector (c) an element selector
- 20.🧩 Which language changes the text size? (a) JavaScript (b) HTML (c) CSS
- 21.🌈 Which hex code is blue? (a) #000000 (b) #00ff00 (c) #ff00ff (d) #0000ff
- 22.True or false: .big is an id selector. (a) False (b) True
- 23.✍️ How does a CSS comment start? (a) // (b) <!-- (c) # (d) /*
-
24.✍️ How many declarations (property: value pairs) are in this rule?
#top {
font-weight: bold;
color: red;
} - 25.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) exactly 1000px (c) 600px or wider (d) 600px or narrower
- 26.Which of these does CSS do? (a) adds space around boxes (b) makes a link (c) reacts to a button click (d) gives the page structure
-
27.✍️ How many declarations (property: value pairs) are in this rule?
li {
font-size: 20px;
background-color: yellow;
} -
28.🖌️ Where does the text sit on its line?
h2 {
text-align: center;
background-color: red;
color: yellow;
font-size: 36px;
} (a) on the left (b) in the middle (c) on the right -
29.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 1024px) {
p {
font-size: 14px;
}
} (a) No (b) Yes - 30.✍️ CSS declarations go inside which brackets? (a) ( ) (b) < > (c) { } (d) [ ]
- 31.🌈 Which colour is rgb(255, 0, 255)? (a) yellow (b) magenta (c) blue (d) red
- 32.✍️ In color: blue; which part is the value? (a) color (b) blue (c) ; (d) :
- 33.🌈 What is the biggest number one colour can have in rgb()? (a) 99 (b) 255 (c) 1000 (d) 100
- 34.🎯 Which sign starts a class selector? (a) @ (b) . (c) & (d) #
-
35.⚖️ What colour is the text of this element?
<p class="note" id="intro">Hi</p>
CSS:
.note { color: black; }
.note { color: blue; } (a) blue (b) black (c) yellow (d) purple - 36.💪 Which flexbox property sets space between boxes? (a) gap (b) align-items (c) display: flex (d) justify-content
- 37.What does text-align do? (a) colours behind the text (b) picks the font style (c) makes the text bold (d) centres a heading
- 38.🌈 Which colour is rgb(255, 0, 0)? (a) magenta (b) red (c) white (d) black
-
39.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 160px;
padding: 30px;
border: 4px solid black;
margin: 10px;
} -
40.✍️ How many declarations (property: value pairs) are in this rule?
#top {
font-style: italic;
font-weight: bold;
padding: 8px;
font-size: 20px;
}
Answer key
- red
- p
- blue
- JavaScript
- .box
- equal gaps, none at ends
- True
- False
- 14
- the text or picture
- red
- False
- red
- in the middle
- font-family
- 40
- yellow
- packs boxes at the start
- a class selector
- CSS
- #0000ff
- False
- /*
- 2
- 600px or narrower
- adds space around boxes
- 2
- in the middle
- Yes
- { }
- magenta
- blue
- 255
- .
- blue
- gap
- centres a heading
- red
- 248
- 4
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids