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 of light is strongest in rgb(198, 112, 86)? (a) green (b) blue (c) red
- 2.✍️ Which sign goes between a property and its value? (a) : (b) - (c) = (d) ;
- 3.True or false: margin is space outside the border. (a) True (b) False
-
4.✍️ How many declarations (property: value pairs) are in this rule?
body {
font-weight: bold;
background-color: yellow;
color: red;
} - 5.🎯 What kind of selector is body? (a) an element selector (b) a class selector (c) an id selector
- 6.What does font-weight do? (a) centres a heading (b) makes the text bold (c) makes letters bigger (d) colours behind the text
-
7.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 80px;
padding: 25px;
border: 3px solid black;
margin: 15px;
} - 8.🌈 In #rrggbb, which colour do the first two digits give? (a) red (b) blue (c) black (d) green
- 9.✍️ CSS declarations go inside which brackets? (a) < > (b) [ ] (c) ( ) (d) { }
- 10.What does font-family do? (a) makes letters bigger (b) colours behind the text (c) sets the letter colour (d) picks the font style
-
11.✍️ What value is given to background-color in this rule?
.box {
text-align: center;
background-color: yellow;
color: red;
padding: 8px;
} (a) 8px (b) background-color (c) yellow (d) 10px -
12.✍️ What is the selector in this CSS rule?
#top {
font-style: italic;
margin: 10px;
font-size: 20px;
} (a) font-style (b) li (c) #top (d) 10px - 13.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or narrower (c) turned off (d) 600px or wider
- 14.🎯 How many elements on a page should have the same id? (a) 5 (b) any number (c) 2 (d) 1
-
15.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 170px;
justify-content: space-between;
}
Inside are 2 boxes, each 50px wide (no margins). -
16.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 12px;
}
} - 17.📱 What does a media query check? (a) the battery level (b) the time of day (c) the page title (d) the screen width
- 18.What does justify-content: flex-start do? (a) equal gaps, none at ends (b) packs boxes at the end (c) packs boxes at the start (d) puts boxes in the middle
-
19.✍️ What is the selector in this CSS rule?
.box {
background-color: yellow;
font-weight: bold;
width: 300px;
} (a) bold (b) .box (c) h2 (d) background-color - 20.🎯 Which element does the selector h1 style? (a) <li class="box"> (b) <h2> (c) <div id="intro"> (d) <h1 class="box">
-
21.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 90px;
padding: 15px;
border: 3px solid black;
margin: 0px;
} -
22.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 230px;
justify-content: flex-start;
}
Inside are 3 boxes, each 60px wide (no margins). -
23.⚖️ What colour is the text of this element?
<h2 class="big" id="intro">Hi</h2>
CSS:
#intro { color: blue; }
#intro { color: white; } (a) yellow (b) purple (c) white (d) blue -
24.✍️ What is the selector in this CSS rule?
body {
font-style: italic;
width: 300px;
} (a) 300px (b) font-style (c) body (d) .box - 25.🎯 Which element does the selector p style? (a) <li id="logo"> (b) <p class="red"> (c) <h2 class="red"> (d) <h1>
- 26.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) blue (c) red (d) white
- 27.🧩 Which language checks a quiz answer? (a) CSS (b) JavaScript (c) HTML
- 28.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
- 29.Which of these does HTML do? (a) shows a pop-up message (b) counts down a timer (c) puts a picture on a page (d) reacts to a button click
- 30.🧩 Which language reacts to a button click? (a) CSS (b) HTML (c) JavaScript
- 31.True or false: margin is the line round the box. (a) False (b) True
- 32.🌈 Which colour is rgb(0, 255, 255)? (a) cyan (b) red (c) bright green (d) white
- 33.True or false: CSS puts a picture on a page. (a) True (b) False
- 34.What does background-color do? (a) makes the text bold (b) sets the letter colour (c) centres a heading (d) colours behind the text
-
35.✍️ What is the selector in this CSS rule?
h2 {
text-align: center;
width: 300px;
border: 2px solid;
background-color: yellow;
} (a) text-align (b) 300px (c) h2 (d) h1 - 36.🖌️ Which CSS property makes the text bold? (a) background-color (b) font-weight (c) color (d) font-family
- 37.True or false: .menu is a class selector. (a) False (b) True
- 38.🧩 Which language sets colours and fonts? (a) CSS (b) HTML (c) JavaScript
- 39.🔍 Which is the odd one out? (a) reacts to a button click (b) counts down a timer (c) shows a pop-up message (d) makes a form box
-
40.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 40px;
padding: 5px;
border: 3px solid black;
margin: 15px;
}
Answer key
- red
- :
- True
- 3
- an element selector
- makes the text bold
- 166
- red
- { }
- picks the font style
- yellow
- #top
- 600px or narrower
- 1
- 70
- 16
- the screen width
- packs boxes at the start
- .box
- <h1 class="box">
- 126
- 50
- white
- body
- <p class="red">
- blue
- JavaScript
- an id selector
- puts a picture on a page
- JavaScript
- False
- cyan
- False
- colours behind the text
- h2
- font-weight
- True
- CSS
- makes a form box
- 86
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids