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 colour is rgb(0, 255, 255)? (a) magenta (b) red (c) blue (d) cyan
- 2.True or false: JavaScript makes headings and lists. (a) True (b) False
-
3.⚖️ What colour is the text of this element?
<h2 class="box" id="main">Hi</h2>
CSS:
h2 { color: purple; }
h2 { color: black; } (a) white (b) blue (c) purple (d) black - 4.True or false: JavaScript rounds box corners. (a) False (b) True
-
5.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 80px;
padding: 10px;
border: 1px solid black;
margin: 0px;
} - 6.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the first one (c) neither (d) the later one
- 7.🖌️ Which CSS property makes letters bigger? (a) color (b) font-size (c) font-weight (d) font-family
- 8.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
- 9.True or false: li is an element selector. (a) False (b) True
- 10.Which of these is margin? (a) the text or picture (b) the gap to other boxes (c) space inside the border (d) a solid or dotted edge
-
11.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} (a) No (b) Yes - 12.🌈 Which hex code is red? (a) #00ff00 (b) #ffff00 (c) #0000ff (d) #ff0000
-
13.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 150px;
padding: 5px;
border: 4px solid black;
margin: 20px;
} -
14.✍️ What value is given to background-color in this rule?
#top {
width: 300px;
font-style: italic;
background-color: yellow;
} (a) background-color (b) 8px (c) yellow (d) 10px - 15.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) turned off (c) 800px or wider (d) exactly 100px
- 16.Which of these is padding? (a) a solid or dotted edge (b) space outside the border (c) space inside the border (d) the line round the box
- 17.💪 Which flexbox property picks row or column? (a) justify-content (b) display: flex (c) flex-direction (d) gap
- 18.🌈 Which colour is rgb(255, 255, 255)? (a) blue (b) white (c) black (d) yellow
- 19.🌈 Which hex code is bright green? (a) #00ff00 (b) #00ffff (c) #0000ff (d) #ffffff
- 20.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) green (c) red (d) white
- 21.🎯 Which sign starts a class selector? (a) # (b) . (c) @ (d) &
- 22.What does text-align do? (a) makes the text bold (b) picks the font style (c) colours behind the text (d) centres a heading
-
23.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 40px;
padding: 5px;
border: 5px solid black;
margin: 10px;
} - 24.Which of these does JavaScript do? (a) rounds box corners (b) sets colours and fonts (c) checks a quiz answer (d) makes a link
- 25.🌈 Hex digits go 0 to 9, then A to which letter? (a) J (b) G (c) F (d) Z
-
26.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 8px;
}
} - 27.🖌️ Which CSS property colours behind the text? (a) background-color (b) font-weight (c) text-align (d) font-family
- 28.🌈 Which hex code is yellow? (a) #000000 (b) #ffff00 (c) #00ff00 (d) #ff0000
-
29.⚖️ What colour is the text of this element?
<h1 class="big" id="logo">Hi</h1>
CSS:
.big { color: black; }
.big { color: white; } (a) purple (b) white (c) green (d) black -
30.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 30px;
}
} - 31.🌈 Which colour is #00ff00? (a) red (b) magenta (c) bright green (d) white
-
32.🎯 Which CSS selector matches this element?
<li class="red" id="hero">Hello</li> (a) .box (b) li (c) #red (d) div -
33.⚖️ What colour is the text of this element?
<p class="star" id="top">Hi</p>
CSS:
#top { color: white; }
#top { color: green; } (a) green (b) blue (c) black (d) white -
34.⚖️ What colour is the text of this element?
<h2 class="menu" id="hero">Hi</h2>
CSS:
#hero { color: white; }
#hero { color: yellow; } (a) white (b) yellow (c) blue (d) orange -
35.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
font-style: italic;
} -
36.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 90px;
justify-content: space-between;
}
Inside are 2 boxes, each 40px wide (no margins). - 37.True or false: p is a class selector. (a) False (b) True
- 38.🖌️ Which CSS property centres a heading? (a) text-align (b) background-color (c) font-weight (d) font-size
- 39.True or false: margin is space inside the border. (a) False (b) True
- 40.🧩 Which language counts down a timer? (a) HTML (b) CSS (c) JavaScript
Answer key
- cyan
- False
- black
- False
- 102
- the later one
- font-size
- an element selector
- True
- the gap to other boxes
- Yes
- #ff0000
- 208
- yellow
- 800px or wider
- space inside the border
- flex-direction
- white
- #00ff00
- blue
- .
- centres a heading
- 80
- checks a quiz answer
- F
- 12
- background-color
- #ffff00
- white
- 24
- bright green
- li
- green
- yellow
- 1
- 10
- False
- text-align
- False
- JavaScript
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids