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.✍️ How many declarations (property: value pairs) are in this rule?
#top {
font-style: italic;
border: 2px solid;
} - 2.🌈 Which colour of light is strongest in rgb(12, 63, 190)? (a) red (b) blue (c) green
- 3.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 3 (b) 4 (c) 6 (d) 2
- 4.🖌️ Which CSS property centres a heading? (a) text-align (b) font-weight (c) background-color (d) color
-
5.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 250px;
padding: 30px;
border: 5px solid black;
margin: 0px;
} -
6.⚖️ What colour is the text of this element?
<h2 class="star" id="hero">Hi</h2>
CSS:
h2 { color: red; }
#hero { color: purple; }
.star { color: green; } (a) green (b) purple (c) red (d) blue -
7.🎯 Which CSS selector matches this element?
<h1 class="red" id="top">Hello</h1> (a) h2 (b) .red (c) #intro (d) .box -
8.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 160px;
justify-content: center;
}
Inside are 2 boxes, each 60px wide (no margins). - 9.⚖️ Which selector is the weakest? (a) an element selector (b) an id selector (c) a class selector
-
10.🎯 Which CSS selector matches this element?
<h1 class="note" id="logo">Hello</h1> (a) #note (b) .logo (c) h2 (d) .note -
11.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 20px;
}
@media (min-width: 480px) {
p {
font-size: 26px;
}
} - 12.What does font-family do? (a) centres a heading (b) makes the text bold (c) makes letters bigger (d) picks the font style
- 13.🔍 Which is the odd one out? (a) reacts to a button click (b) makes headings and lists (c) changes the page live (d) shows a pop-up message
-
14.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 180px;
padding: 30px;
border: 2px solid black;
margin: 15px;
} -
15.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 12px;
}
} (a) Yes (b) No -
16.✍️ How many declarations (property: value pairs) are in this rule?
#top {
margin: 10px;
border: 2px solid;
color: red;
} -
17.✍️ Which property is set to 8px in this rule?
p {
border: 2px solid;
text-align: center;
padding: 8px;
} (a) 8px (b) font-weight (c) padding (d) border - 18.🎨 One CSS file can style how many pages? (a) no pages (b) only one word (c) only one image (d) many pages
-
19.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-style: italic;
margin: 10px;
} - 20.True or false: #hero is an id selector. (a) False (b) True
- 21.💪 Which flexbox property lines boxes up across? (a) align-items (b) display: flex (c) gap (d) flex-direction
- 22.True or false: .star is an element selector. (a) False (b) True
-
23.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 260px;
padding: 5px;
border: 1px solid black;
margin: 10px;
} - 24.🌈 Which colour is rgb(255, 0, 255)? (a) black (b) magenta (c) yellow (d) bright green
-
25.⚖️ What colour is the text of this element?
<p class="menu" id="top">Hi</p>
CSS:
p { color: black; }
p { color: white; } (a) white (b) blue (c) black (d) green -
26.✍️ Which property is set to 8px in this rule?
.note {
padding: 8px;
background-color: yellow;
font-size: 20px;
text-align: center;
} (a) border (b) font-weight (c) 8px (d) padding -
27.⚖️ What colour is the text of this element?
<h1 class="box" id="hero">Hi</h1>
CSS:
.box { color: yellow; }
h1 { color: blue; }
#hero { color: white; } (a) white (b) blue (c) yellow (d) black -
28.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 60px;
padding: 30px;
border: 1px solid black;
margin: 15px;
} -
29.✍️ Which property is set to 2px solid in this rule?
h2 {
padding: 8px;
width: 300px;
text-align: center;
border: 2px solid;
} (a) width (b) border (c) font-style (d) 2px solid - 30.📱 min-width: 800px applies when the screen is ___. (a) 800px or wider (b) 800px or narrower (c) turned off (d) exactly 100px
- 31.🌈 What is the biggest number one colour can have in rgb()? (a) 99 (b) 100 (c) 1000 (d) 255
- 32.📱 Responsive design means a page ___. (a) never changes (b) is only for laptops (c) fits every screen (d) has no pictures
- 33.💪 Which flexbox property picks row or column? (a) align-items (b) justify-content (c) flex-direction (d) gap
-
34.⚖️ What colour is the text of this element?
<h1 class="menu" id="hero">Hi</h1>
CSS:
.menu { color: white; }
h1 { color: black; }
#hero { color: red; } (a) black (b) red (c) white (d) green - 35.🎯 What kind of selector is p? (a) a class selector (b) an element selector (c) an id selector
- 36.🎯 Which element does the selector span style? (a) <h2 id="end"> (b) <span class="box"> (c) <h1 class="box"> (d) <p>
- 37.True or false: #top is an id selector. (a) True (b) False
- 38.🌈 Which hex code is black? (a) #000000 (b) #ffff00 (c) #ffffff (d) #0000ff
- 39.Which of these does JavaScript do? (a) makes a link (b) rounds box corners (c) makes a form box (d) checks a quiz answer
-
40.✍️ What value is given to font-size in this rule?
li {
font-size: 20px;
width: 300px;
font-style: italic;
background-color: yellow;
} (a) center (b) 20px (c) font-size (d) yellow
Answer key
- 2
- blue
- 3
- text-align
- 320
- purple
- .red
- 20
- an element selector
- .note
- 20
- picks the font style
- makes headings and lists
- 274
- No
- 3
- padding
- many pages
- 2
- True
- align-items
- False
- 272
- magenta
- white
- padding
- white
- 152
- border
- 800px or wider
- 255
- fits every screen
- flex-direction
- red
- an element selector
- <span class="box">
- True
- #000000
- checks a quiz answer
- 20px
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids