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 flexbox property sets space between boxes? (a) display: flex (b) flex-direction (c) gap (d) align-items
- 2.🎯 Which sign starts an id selector? (a) # (b) @ (c) & (d) .
-
3.✍️ How many declarations (property: value pairs) are in this rule?
li {
color: red;
} - 4.🎨 Which tag holds CSS inside the head? (a) <css> (b) <script> (c) <style> (d) <body>
- 5.True or false: margin is the gap round content. (a) False (b) True
- 6.🌈 Which colour of light is strongest in rgb(21, 156, 117)? (a) blue (b) green (c) red
- 7.🌈 Which colour of light is strongest in rgb(180, 114, 53)? (a) blue (b) red (c) green
- 8.🌈 In #rrggbb, which colour do the first two digits give? (a) red (b) green (c) blue (d) black
-
9.⚖️ What colour is the text of this element?
<h1 class="big" id="main">Hi</h1>
CSS:
h1 { color: green; }
.big { color: white; }
#main { color: purple; } (a) purple (b) white (c) green (d) blue - 10.📦 In the box model, which part is a solid or dotted edge? (a) padding (b) border (c) content (d) margin
- 11.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) 800px or wider (c) turned off (d) exactly 100px
-
12.🖌️ Where does the text sit on its line?
h2 {
background-color: yellow;
text-align: left;
font-size: 32px;
color: white;
} (a) in the middle (b) on the left (c) on the right -
13.✍️ What is the selector in this CSS rule?
p {
font-size: 20px;
margin: 10px;
} (a) p (b) font-size (c) .note (d) 10px - 14.💪 Which justify-content value packs boxes at the start? (a) center (b) flex-start (c) flex-end (d) space-between
- 15.True or false: .card is an element selector. (a) False (b) True
-
16.📦 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: 4px solid black;
margin: 15px;
} - 17.🌈 Which hex code is red? (a) #000000 (b) #ffffff (c) #00ff00 (d) #ff0000
- 18.✍️ In color: blue; which part is the value? (a) color (b) : (c) blue (d) ;
- 19.What does background-color do? (a) centres a heading (b) sets the letter colour (c) makes letters bigger (d) colours behind the text
- 20.True or false: padding is space outside the border. (a) True (b) False
- 21.🌈 Which hex code is yellow? (a) #ffff00 (b) #00ff00 (c) #000000 (d) #ff00ff
-
22.⚖️ What colour is the text of this element?
<h2 class="big" id="end">Hi</h2>
CSS:
h2 { color: blue; }
.big { color: green; } (a) yellow (b) green (c) blue (d) orange - 23.🧩 Which language adds space around boxes? (a) HTML (b) JavaScript (c) CSS
-
24.✍️ Which property is set to 20px in this rule?
#top {
text-align: center;
font-size: 20px;
width: 300px;
padding: 8px;
} (a) 20px (b) font-size (c) text-align (d) background-color - 25.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
-
26.✍️ What value is given to color in this rule?
p {
color: red;
background-color: yellow;
font-weight: bold;
} (a) 20px (b) center (c) color (d) red - 27.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) neither (c) the shorter one (d) the later one
- 28.🌈 Which colour of light is strongest in rgb(129, 176, 112)? (a) red (b) green (c) blue
- 29.🌈 Which colour is rgb(255, 255, 255)? (a) white (b) blue (c) yellow (d) red
- 30.🎯 What kind of selector is p? (a) a class selector (b) an id selector (c) an element selector
- 31.🌈 Which colour is #000000? (a) bright green (b) black (c) magenta (d) white
- 32.🧩 Which language makes headings and lists? (a) JavaScript (b) HTML (c) CSS
- 33.🌈 Which colour is rgb(255, 0, 255)? (a) red (b) black (c) white (d) magenta
-
34.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 1024px) {
p {
font-size: 14px;
}
} (a) No (b) Yes -
35.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 210px;
padding: 5px;
border: 4px solid black;
margin: 5px;
} - 36.✍️ CSS declarations go inside which brackets? (a) [ ] (b) < > (c) ( ) (d) { }
- 37.🎯 What kind of selector is .menu? (a) a class selector (b) an id selector (c) an element selector
-
38.⚖️ What colour is the text of this element?
<h2 class="big" id="hero">Hi</h2>
CSS:
h2 { color: purple; }
h2 { color: blue; } (a) yellow (b) purple (c) blue (d) green - 39.Which of these does JavaScript do? (a) makes a form box (b) checks a quiz answer (c) makes a link (d) makes headings and lists
-
40.✍️ Which property is set to 20px in this rule?
p {
background-color: yellow;
width: 300px;
font-size: 20px;
color: red;
} (a) text-align (b) 20px (c) font-size (d) background-color
Answer key
- gap
- #
- 1
- <style>
- False
- green
- red
- red
- purple
- border
- 800px or wider
- on the left
- p
- flex-start
- False
- 188
- #ff0000
- blue
- colours behind the text
- False
- #ffff00
- green
- CSS
- font-size
- an id selector
- red
- the later one
- green
- white
- an element selector
- black
- HTML
- magenta
- No
- 228
- { }
- a class selector
- blue
- checks a quiz answer
- font-size
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids