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 attribute adds CSS inside one tag? (a) src (b) href (c) alt (d) style
- 2.🎨 Which tag holds CSS inside the head? (a) <body> (b) <script> (c) <css> (d) <style>
- 3.✍️ How does a CSS comment start? (a) // (b) <!-- (c) /* (d) #
-
4.✍️ Which property is set to 10px in this rule?
body {
font-size: 20px;
margin: 10px;
font-style: italic;
} (a) 10px (b) margin (c) font-weight (d) padding -
5.🖌️ How big is the text, in px?
p {
font-size: 24px;
text-align: center;
background-color: blue;
color: black;
} - 6.True or false: padding is space inside the border. (a) True (b) False
- 7.Which of these does CSS do? (a) makes headings and lists (b) reacts to a button click (c) changes the page live (d) lays out the page
-
8.✍️ What value is given to font-size in this rule?
h1 {
font-size: 20px;
padding: 8px;
} (a) font-size (b) center (c) yellow (d) 20px - 9.🌈 Which colour is #0000ff? (a) black (b) blue (c) red (d) yellow
- 10.✍️ CSS declarations go inside which brackets? (a) < > (b) [ ] (c) { } (d) ( )
- 11.🎯 What kind of selector is .big? (a) an element selector (b) a class selector (c) an id selector
- 12.🎯 Which element does the selector #intro style? (a) <span id="main"> (b) <span id="intro"> (c) <p class="note"> (d) <span class="intro">
- 13.True or false: .menu is an id selector. (a) True (b) False
- 14.💪 Which justify-content value equal gaps, none at ends? (a) flex-start (b) center (c) flex-end (d) space-between
-
15.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 340px;
justify-content: space-between;
}
Inside are 4 boxes, each 40px wide (no margins). -
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: 280px;
padding: 5px;
border: 3px solid black;
margin: 0px;
} - 17.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
- 18.🔍 Which is the odd one out? (a) puts a picture on a page (b) adds space around boxes (c) makes a link (d) gives the page structure
- 19.Which of these does JavaScript do? (a) counts down a timer (b) gives the page structure (c) adds space around boxes (d) rounds box corners
-
20.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 270px;
justify-content: flex-start;
}
Inside are 3 boxes, each 80px wide (no margins). - 21.🖌️ Which CSS property sets the letter colour? (a) color (b) font-size (c) background-color (d) text-align
- 22.⚖️ 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
- 23.True or false: padding is the gap round content. (a) True (b) False
-
24.🎯 Which CSS selector matches this element?
<h1 class="big" id="main">Hello</h1> (a) h2 (b) .main (c) .red (d) #main - 25.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) 800px or wider (c) 800px or narrower (d) exactly 100px
-
26.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 90px;
padding: 30px;
border: 4px solid black;
margin: 20px;
} - 27.🧩 Which language changes the text size? (a) CSS (b) HTML (c) JavaScript
-
28.🖌️ How big is the text, in px?
li {
background-color: red;
font-size: 16px;
text-align: left;
color: blue;
} - 29.What does font-weight do? (a) makes the text bold (b) picks the font style (c) colours behind the text (d) sets the letter colour
-
30.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 150px;
justify-content: space-between;
}
Inside are 2 boxes, each 60px wide (no margins). - 31.🎯 Can many elements share the same class? (a) Yes (b) No
- 32.🌈 Which colour of light is strongest in rgb(166, 47, 84)? (a) blue (b) green (c) red
-
33.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
font-size: 20px;
color: red;
} - 34.🌈 Which colour of light is strongest in rgb(210, 117, 138)? (a) green (b) blue (c) red
- 35.True or false: HTML lays out the page. (a) False (b) True
- 36.🌈 In #007500 the green part is the hex number 75. What is it as a normal number?
- 37.🌈 Which colour is rgb(255, 0, 255)? (a) red (b) yellow (c) magenta (d) black
-
38.🎯 Which CSS selector matches this element?
<p class="big" id="end">Hello</p> (a) .end (b) h1 (c) .big (d) #hero - 39.🧩 Which language makes headings and lists? (a) HTML (b) CSS (c) JavaScript
-
40.🖌️ What colour are the letters?
h1 {
color: yellow;
font-size: 28px;
text-align: right;
background-color: orange;
} (a) red (b) orange (c) yellow
Answer key
- style
- <style>
- /*
- margin
- 24
- True
- lays out the page
- 20px
- blue
- { }
- a class selector
- <span id="intro">
- False
- space-between
- 60
- 296
- an id selector
- adds space around boxes
- counts down a timer
- 30
- color
- the later one
- True
- #main
- 800px or wider
- 158
- CSS
- 16
- makes the text bold
- 30
- Yes
- red
- 2
- red
- False
- 117
- magenta
- .big
- HTML
- yellow
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids