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 are the letters?
p {
text-align: left;
font-size: 20px;
background-color: red;
color: orange;
} (a) red (b) orange (c) black -
2.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 768px) {
p {
font-size: 10px;
}
} - 3.⚖️ 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
- 4.🌈 Hex digits go 0 to 9, then A to which letter? (a) G (b) J (c) Z (d) F
- 5.✍️ In color: blue; which part is the value? (a) : (b) ; (c) blue (d) color
-
6.⚖️ What colour is the text of this element?
<p class="box" id="intro">Hi</p>
CSS:
p { color: green; }
p { color: red; } (a) purple (b) red (c) green (d) blue -
7.⚖️ What colour is the text of this element?
<h2 class="big" id="intro">Hi</h2>
CSS:
h2 { color: white; }
h2 { color: red; } (a) yellow (b) blue (c) white (d) red -
8.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 120px;
padding: 5px;
border: 5px solid black;
margin: 0px;
} -
9.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 8px;
}
} - 10.💪 Which flexbox property spaces boxes along a row? (a) flex-direction (b) justify-content (c) gap (d) display: flex
- 11.🌈 Which colour is #ffffff? (a) white (b) magenta (c) black (d) blue
- 12.✍️ In color: blue; which part is the property? (a) : (b) ; (c) color (d) blue
- 13.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) exactly 1000px (c) 600px or narrower (d) turned off
- 14.🎯 Which sign starts a class selector? (a) @ (b) & (c) . (d) #
-
15.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 110px;
padding: 25px;
border: 5px solid black;
margin: 15px;
} -
16.🖌️ Where does the text sit on its line?
h1 {
background-color: purple;
text-align: right;
font-size: 32px;
color: red;
} (a) on the right (b) on the left (c) in the middle - 17.🌈 Which colour is #ff0000? (a) blue (b) black (c) red (d) yellow
-
18.🖌️ Where does the text sit on its line?
p {
font-size: 16px;
background-color: yellow;
text-align: left;
color: purple;
} (a) on the right (b) in the middle (c) on the left -
19.🎯 Which CSS selector matches this element?
<div class="big" id="intro">Hello</div> (a) .intro (b) #intro (c) .red (d) span - 20.🎯 Which element does the selector #hero style? (a) <h1 id="top"> (b) <h1 class="hero"> (c) <h2 class="menu"> (d) <h1 id="hero">
- 21.🎯 How many elements on a page should have the same id? (a) 5 (b) 2 (c) any number (d) 1
- 22.📦 In the box model, which part is the line round the box? (a) padding (b) margin (c) content (d) border
- 23.🌈 Which hex code is yellow? (a) #000000 (b) #00ffff (c) #ff0000 (d) #ffff00
- 24.True or false: .note is an element selector. (a) False (b) True
-
25.🖌️ How big is the text, in px?
p {
text-align: right;
color: white;
font-size: 12px;
background-color: red;
} - 26.🌈 In #rrggbb, which colour do the first two digits give? (a) black (b) blue (c) red (d) green
- 27.🎯 Which element does the selector #intro style? (a) <li id="main"> (b) <li id="intro"> (c) <div class="note"> (d) <li class="intro">
- 28.🧩 Which language makes a link? (a) JavaScript (b) HTML (c) CSS
- 29.Which of these does JavaScript do? (a) lays out the page (b) puts a picture on a page (c) makes a form box (d) reacts to a button click
-
30.🖌️ What colour are the letters?
h1 {
font-size: 40px;
background-color: white;
color: purple;
text-align: center;
} (a) purple (b) red (c) white -
31.⚖️ What colour is the text of this element?
<h2 class="big" id="hero">Hi</h2>
CSS:
h2 { color: yellow; }
h2 { color: white; } (a) blue (b) yellow (c) black (d) white - 32.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 4 (b) 6 (c) 2 (d) 3
- 33.🌈 Which colour is #00ff00? (a) white (b) black (c) magenta (d) bright green
- 34.🎯 What kind of selector is img? (a) an id selector (b) a class selector (c) an element selector
-
35.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 220px;
justify-content: flex-end;
}
Inside are 4 boxes, each 50px wide (no margins). - 36.What does font-weight do? (a) sets the letter colour (b) makes the text bold (c) makes letters bigger (d) colours behind the text
- 37.True or false: #logo is a class selector. (a) True (b) False
-
38.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 30px;
}
} (a) Yes (b) No -
39.✍️ How many declarations (property: value pairs) are in this rule?
.note {
width: 300px;
} -
40.✍️ What value is given to margin in this rule?
.box {
border: 2px solid;
margin: 10px;
} (a) margin (b) 8px (c) bold (d) 10px
Answer key
- orange
- 10
- the later one
- F
- blue
- red
- red
- 140
- 8
- justify-content
- white
- color
- 600px or narrower
- .
- 170
- on the right
- red
- on the left
- #intro
- <h1 id="hero">
- 1
- border
- #ffff00
- False
- 12
- red
- <li id="intro">
- HTML
- reacts to a button click
- purple
- white
- 3
- bright green
- an element selector
- 20
- makes the text bold
- False
- No
- 1
- 10px
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids