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.🖌️ Where does the text sit on its line?
h1 {
text-align: center;
color: yellow;
background-color: black;
font-size: 36px;
} (a) on the left (b) in the middle (c) on the right -
2.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 110px;
padding: 15px;
border: 4px solid black;
margin: 15px;
} - 3.✍️ Which sign ends each CSS declaration? (a) : (b) . (c) ; (d) ,
- 4.Which of these is the content? (a) space inside the border (b) the gap round content (c) the text or picture (d) a solid or dotted edge
- 5.💪 Which justify-content value puts boxes in the middle? (a) center (b) space-between (c) flex-end (d) flex-start
- 6.🌈 Which colour is #0000ff? (a) black (b) magenta (c) bright green (d) blue
- 7.🔍 Which is the odd one out? (a) makes a form box (b) puts a picture on a page (c) gives the page structure (d) changes the text size
- 8.✍️ CSS declarations go inside which brackets? (a) ( ) (b) { } (c) [ ] (d) < >
-
9.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 20px;
}
} (a) No (b) Yes -
10.🎯 Which CSS selector matches this element?
<p class="star" id="top">Hello</p> (a) #intro (b) .star (c) h1 (d) #star - 11.Which of these does HTML do? (a) counts down a timer (b) reacts to a button click (c) gives the page structure (d) lays out the page
-
12.💪 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). - 13.🌈 In #rrggbb, which colour do the first two digits give? (a) red (b) blue (c) green (d) black
-
14.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 120px;
padding: 30px;
border: 5px solid black;
margin: 15px;
} - 15.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
-
16.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 280px;
padding: 5px;
border: 5px solid black;
margin: 0px;
} - 17.Which of these is padding? (a) the gap to other boxes (b) the text or picture (c) space inside the border (d) a solid or dotted edge
- 18.🎨 Which attribute adds CSS inside one tag? (a) src (b) alt (c) style (d) href
- 19.True or false: .card is a class selector. (a) False (b) True
- 20.🖌️ Which CSS property colours behind the text? (a) font-weight (b) background-color (c) font-size (d) color
-
21.📦 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: 1px solid black;
margin: 0px;
} - 22.🌈 What is the biggest number one colour can have in rgb()? (a) 1000 (b) 255 (c) 100 (d) 99
- 23.🖌️ Which CSS property centres a heading? (a) font-family (b) text-align (c) font-size (d) background-color
- 24.🧩 Which language changes the page live? (a) JavaScript (b) CSS (c) HTML
- 25.Which of these does HTML do? (a) checks a quiz answer (b) rounds box corners (c) makes a form box (d) changes the text size
- 26.True or false: #hero is an element selector. (a) True (b) False
- 27.🎯 What kind of selector is #hero? (a) a class selector (b) an element selector (c) an id selector
-
28.📱 The screen is 320px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (max-width: 480px) {
p {
font-size: 16px;
}
} (a) Yes (b) No - 29.True or false: #logo is an element selector. (a) True (b) False
-
30.🖌️ What colour are the letters?
li {
color: orange;
background-color: yellow;
font-size: 24px;
text-align: right;
} (a) purple (b) orange (c) yellow -
31.✍️ What is the selector in this CSS rule?
h2 {
border: 2px solid;
font-weight: bold;
text-align: center;
} (a) h2 (b) border (c) h1 (d) bold -
32.🖌️ What colour is behind the letters?
p {
color: orange;
text-align: center;
font-size: 40px;
background-color: white;
} (a) orange (b) blue (c) white -
33.🖌️ What colour is behind the letters?
h1 {
background-color: green;
text-align: left;
font-size: 24px;
color: yellow;
} (a) green (b) yellow (c) black -
34.✍️ What is the selector in this CSS rule?
h1 {
background-color: yellow;
color: red;
text-align: center;
} (a) red (b) h1 (c) p (d) background-color - 35.What does font-family do? (a) picks the font style (b) sets the letter colour (c) colours behind the text (d) makes the text bold
- 36.🧩 Which language lays out the page? (a) HTML (b) CSS (c) JavaScript
- 37.🖌️ Which CSS property makes the text bold? (a) text-align (b) font-weight (c) font-size (d) background-color
-
38.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 1024px) {
p {
font-size: 26px;
}
} - 39.What does color do? (a) colours behind the text (b) sets the letter colour (c) centres a heading (d) picks the font style
-
40.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 100px;
padding: 20px;
border: 3px solid black;
margin: 10px;
}
Answer key
- in the middle
- 178
- ;
- the text or picture
- center
- blue
- changes the text size
- { }
- No
- .star
- gives the page structure
- 30
- red
- 190
- an element selector
- 300
- space inside the border
- style
- True
- background-color
- 162
- 255
- text-align
- JavaScript
- makes a form box
- False
- an id selector
- Yes
- False
- orange
- h2
- white
- green
- h1
- picks the font style
- CSS
- font-weight
- 26
- sets the letter colour
- 146
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids