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="big" id="top">Hi</h1>
CSS:
h1 { color: red; }
h1 { color: blue; } (a) red (b) black (c) blue (d) white -
2.✍️ What is the selector in this CSS rule?
h2 {
font-size: 20px;
color: red;
} (a) red (b) h1 (c) font-size (d) h2 - 3.What does color do? (a) sets the letter colour (b) colours behind the text (c) makes letters bigger (d) makes the text bold
- 4.✍️ Which sign ends each CSS declaration? (a) . (b) : (c) ; (d) ,
- 5.True or false: margin is space outside the border. (a) True (b) False
- 6.🌈 Which hex code is white? (a) #000000 (b) #ff0000 (c) #ffffff (d) #00ff00
-
7.🎯 Which CSS selector matches this element?
<h2 class="big" id="main">Hello</h2> (a) #big (b) h2 (c) #logo (d) .main - 8.🧩 Which language counts down a timer? (a) HTML (b) JavaScript (c) CSS
- 9.💪 Which flexbox property turns on flexbox? (a) align-items (b) display: flex (c) flex-direction (d) justify-content
- 10.Which of these does JavaScript do? (a) gives the page structure (b) checks a quiz answer (c) changes the text size (d) puts a picture on a page
- 11.🌈 In #630000 the red part is the hex number 63. What is it as a normal number?
-
12.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 50px;
padding: 20px;
border: 1px solid black;
margin: 5px;
} -
13.🖌️ Where does the text sit on its line?
h2 {
font-size: 40px;
color: blue;
background-color: red;
text-align: center;
} (a) in the middle (b) on the left (c) on the right - 14.True or false: body is an id selector. (a) True (b) False
- 15.📱 Which tag helps phones show a page at the right size? (a) the viewport meta tag (b) the title tag (c) the hr tag (d) the br tag
-
16.🖌️ How big is the text, in px?
p {
color: green;
font-size: 20px;
background-color: yellow;
text-align: center;
} -
17.✍️ What is the selector in this CSS rule?
#top {
color: red;
width: 300px;
} (a) #top (b) 300px (c) li (d) color - 18.True or false: CSS lays out the page. (a) True (b) False
- 19.🎯 Which sign starts an id selector? (a) @ (b) # (c) . (d) &
- 20.Which of these is padding? (a) the gap round content (b) the line round the box (c) the text or picture (d) space outside the border
- 21.🌈 Which colour of light is strongest in rgb(152, 29, 61)? (a) blue (b) red (c) green
- 22.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) exactly 100px (c) 800px or wider (d) turned off
- 23.Which of these does CSS do? (a) makes a form box (b) checks a quiz answer (c) lays out the page (d) changes the page live
-
24.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 600px) {
p {
font-size: 14px;
}
} - 25.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the first one (c) neither (d) the shorter one
-
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: 230px;
padding: 5px;
border: 2px solid black;
margin: 20px;
} -
27.✍️ Which property is set to 20px in this rule?
.box {
text-align: center;
background-color: yellow;
font-size: 20px;
} (a) background-color (b) text-align (c) 20px (d) font-size - 28.🧩 Which language puts a picture on a page? (a) CSS (b) JavaScript (c) HTML
- 29.🌈 Which colour is rgb(255, 0, 255)? (a) magenta (b) black (c) red (d) yellow
-
30.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 600px) {
p {
font-size: 30px;
}
} (a) No (b) Yes - 31.🎯 Which element does the selector #end style? (a) <h2 class="end"> (b) <h2 id="hero"> (c) <li class="note"> (d) <h2 id="end">
- 32.✍️ Which sign goes between a property and its value? (a) : (b) = (c) ; (d) -
- 33.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
- 34.🌈 In #000048 the blue part is the hex number 48. What is it as a normal number?
-
35.🎯 Which CSS selector matches this element?
<li class="red" id="intro">Hello</li> (a) .box (b) #intro (c) div (d) #main - 36.True or false: JavaScript shows a pop-up message. (a) True (b) False
- 37.True or false: padding is the gap to other boxes. (a) True (b) False
- 38.🧩 Which language makes headings and lists? (a) CSS (b) JavaScript (c) HTML
-
39.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 170px;
justify-content: flex-start;
}
Inside are 2 boxes, each 50px wide (no margins). - 40.🌈 In #rrggbb, which colour do the first two digits give? (a) black (b) green (c) blue (d) red
Answer key
- blue
- h2
- sets the letter colour
- ;
- True
- #ffffff
- h2
- JavaScript
- display: flex
- checks a quiz answer
- 99
- 102
- in the middle
- False
- the viewport meta tag
- 20
- #top
- True
- #
- the gap round content
- red
- 800px or wider
- lays out the page
- 14
- the later one
- 244
- font-size
- HTML
- magenta
- No
- <h2 id="end">
- :
- an id selector
- 72
- #intro
- True
- False
- HTML
- 70
- red
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids