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?
.note {
text-align: center;
margin: 10px;
font-style: italic;
} -
2.🖌️ Where does the text sit on its line?
li {
text-align: left;
font-size: 20px;
color: purple;
background-color: red;
} (a) on the right (b) in the middle (c) on the left - 3.🌈 Which hex code is blue? (a) #ff0000 (b) #ffff00 (c) #ff00ff (d) #0000ff
- 4.True or false: padding is the line round the box. (a) True (b) False
-
5.⚖️ What colour is the text of this element?
<p class="menu" id="end">Hi</p>
CSS:
.menu { color: green; }
.menu { color: red; } (a) green (b) purple (c) red (d) yellow - 6.True or false: the content is the gap round content. (a) False (b) True
- 7.What does font-family do? (a) picks the font style (b) centres a heading (c) sets the letter colour (d) colours behind the text
- 8.🎯 Which sign starts an id selector? (a) . (b) # (c) @ (d) &
- 9.🌈 Which colour of light is strongest in rgb(72, 161, 3)? (a) blue (b) green (c) red
- 10.🎨 Which attribute adds CSS inside one tag? (a) src (b) style (c) href (d) alt
-
11.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 190px;
justify-content: space-between;
}
Inside are 4 boxes, each 40px wide (no margins). - 12.🎯 Which element does the selector p style? (a) <h2 class="menu"> (b) <p class="menu"> (c) <li id="logo"> (d) <h1>
-
13.⚖️ What colour is the text of this element?
<h2 class="note" id="logo">Hi</h2>
CSS:
h2 { color: purple; }
#logo { color: green; } (a) green (b) white (c) purple (d) orange - 14.⚖️ Which selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
-
15.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (min-width: 1024px) {
p {
font-size: 30px;
}
} -
16.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 70px;
padding: 30px;
border: 1px solid black;
margin: 10px;
} - 17.🎯 What kind of selector is .menu? (a) a class selector (b) an element selector (c) an id selector
-
18.⚖️ What colour is the text of this element?
<h1 class="big" id="end">Hi</h1>
CSS:
.big { color: red; }
#end { color: purple; } (a) purple (b) green (c) red (d) yellow -
19.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 160px;
justify-content: flex-start;
}
Inside are 3 boxes, each 40px wide (no margins). - 20.🎨 What does CSS stand for? (a) Computer Style Sheets (b) Creative Sheet System (c) Cascading Style Sheets (d) Colourful Site Styles
-
21.✍️ Which property is set to 10px in this rule?
body {
margin: 10px;
border: 2px solid;
font-weight: bold;
text-align: center;
} (a) 10px (b) font-weight (c) padding (d) margin -
22.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 18px;
}
} - 23.🎯 What kind of selector is #top? (a) an id selector (b) an element selector (c) a class selector
-
24.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 210px;
justify-content: flex-start;
}
Inside are 2 boxes, each 100px wide (no margins). - 25.🌈 Hex digits go 0 to 9, then A to which letter? (a) Z (b) F (c) G (d) J
-
26.✍️ Which property is set to 20px in this rule?
li {
margin: 10px;
font-size: 20px;
background-color: yellow;
} (a) background-color (b) 20px (c) text-align (d) font-size - 27.📦 In the box model, which part is space inside the border? (a) border (b) padding (c) margin (d) content
- 28.📦 In the box model, which part is a solid or dotted edge? (a) content (b) padding (c) border (d) margin
- 29.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
-
30.✍️ What value is given to padding in this rule?
p {
font-style: italic;
background-color: yellow;
color: red;
padding: 8px;
} (a) bold (b) 2px solid (c) padding (d) 8px - 31.🎯 Which element does the selector .big style? (a) <span class="box"> (b) <div class="big"> (c) <div id="big"> (d) <div class="red">
- 32.✍️ Which sign ends each CSS declaration? (a) . (b) : (c) , (d) ;
-
33.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (max-width: 480px) {
p {
font-size: 8px;
}
} - 34.True or false: JavaScript reacts to a button click. (a) False (b) True
-
35.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 480px) {
p {
font-size: 12px;
}
} -
36.✍️ How many declarations (property: value pairs) are in this rule?
body {
margin: 10px;
} - 37.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 4 (b) 6 (c) 3 (d) 2
- 38.🖌️ Which CSS property picks the font style? (a) font-weight (b) text-align (c) font-family (d) color
-
39.⚖️ What colour is the text of this element?
<h1 class="red" id="main">Hi</h1>
CSS:
.red { color: yellow; }
.red { color: purple; } (a) yellow (b) black (c) orange (d) purple -
40.⚖️ What colour is the text of this element?
<h1 class="menu" id="hero">Hi</h1>
CSS:
h1 { color: yellow; }
h1 { color: white; } (a) white (b) purple (c) orange (d) yellow
Answer key
- 3
- on the left
- #0000ff
- False
- red
- False
- picks the font style
- #
- green
- style
- 10
- <p class="menu">
- green
- an id selector
- 24
- 152
- a class selector
- purple
- 40
- Cascading Style Sheets
- margin
- 18
- an id selector
- 10
- F
- font-size
- padding
- border
- an element selector
- 8px
- <div class="big">
- ;
- 8
- True
- 16
- 1
- 3
- font-family
- purple
- white
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids