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.🌈 Which colour is rgb(255, 255, 0)? (a) red (b) cyan (c) bright green (d) yellow
-
2.✍️ What is the selector in this CSS rule?
.box {
font-size: 20px;
color: red;
border: 2px solid;
} (a) red (b) h2 (c) font-size (d) .box - 3.Which of these does CSS do? (a) makes a form box (b) puts a picture on a page (c) gives the page structure (d) adds space around boxes
- 4.Which of these does JavaScript do? (a) makes a form box (b) reacts to a button click (c) makes headings and lists (d) makes a link
-
5.🎯 Which CSS selector matches this element?
<h1 class="box" id="intro">Hello</h1> (a) .star (b) h2 (c) h1 (d) #box -
6.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 180px;
justify-content: flex-start;
}
Inside are 2 boxes, each 60px wide (no margins). -
7.🖌️ What colour are the letters?
h1 {
text-align: left;
background-color: green;
font-size: 20px;
color: blue;
} (a) green (b) blue (c) yellow - 8.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
-
9.✍️ What value is given to background-color in this rule?
.box {
background-color: yellow;
margin: 10px;
} (a) yellow (b) 10px (c) 8px (d) background-color -
10.✍️ What value is given to color in this rule?
.note {
color: red;
font-weight: bold;
} (a) color (b) center (c) 20px (d) red -
11.✍️ What value is given to font-style in this rule?
body {
font-style: italic;
width: 300px;
} (a) italic (b) red (c) font-style (d) 20px -
12.✍️ Which property is set to 8px in this rule?
.note {
padding: 8px;
width: 300px;
font-weight: bold;
} (a) font-weight (b) border (c) 8px (d) padding -
13.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (min-width: 768px) {
p {
font-size: 22px;
}
} - 14.✍️ In color: blue; which part is the value? (a) : (b) color (c) blue (d) ;
-
15.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 160px;
justify-content: flex-end;
}
Inside are 2 boxes, each 40px wide (no margins). - 16.✍️ Which sign goes between a property and its value? (a) ; (b) : (c) = (d) -
-
17.⚖️ What colour is the text of this element?
<h1 class="star" id="main">Hi</h1>
CSS:
#main { color: red; }
#main { color: orange; } (a) red (b) white (c) orange (d) purple - 18.🌈 Which colour is #00ff00? (a) blue (b) red (c) black (d) bright green
-
19.🎯 Which CSS selector matches this element?
<h1 class="note" id="main">Hello</h1> (a) #note (b) #logo (c) #main (d) h2 -
20.⚖️ What colour is the text of this element?
<h1 class="star" id="logo">Hi</h1>
CSS:
.star { color: green; }
.star { color: black; } (a) red (b) blue (c) black (d) green - 21.True or false: padding is space outside the border. (a) True (b) False
-
22.✍️ What value is given to background-color in this rule?
.box {
background-color: yellow;
font-size: 20px;
color: red;
} (a) background-color (b) 10px (c) yellow (d) 8px -
23.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 130px;
padding: 30px;
border: 5px solid black;
margin: 10px;
} - 24.🧩 Which language counts down a timer? (a) HTML (b) CSS (c) JavaScript
- 25.💪 Which flexbox property lines boxes up across? (a) gap (b) align-items (c) flex-direction (d) display: flex
- 26.🖌️ Which CSS property picks the font style? (a) color (b) font-family (c) background-color (d) text-align
-
27.✍️ What is the selector in this CSS rule?
.note {
width: 300px;
background-color: yellow;
text-align: center;
margin: 10px;
} (a) #top (b) yellow (c) width (d) .note - 28.🌈 Which colour is #ff00ff? (a) white (b) black (c) magenta (d) bright green
-
29.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 280px;
padding: 15px;
border: 2px solid black;
margin: 15px;
} - 30.💪 Which flexbox property spaces boxes along a row? (a) display: flex (b) gap (c) justify-content (d) align-items
-
31.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 120px;
padding: 30px;
border: 4px solid black;
margin: 5px;
} - 32.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
-
33.📱 The screen is 414px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 600px) {
p {
font-size: 26px;
}
} (a) No (b) Yes -
34.✍️ What value is given to background-color in this rule?
h1 {
font-size: 20px;
color: red;
background-color: yellow;
} (a) 10px (b) background-color (c) yellow (d) 8px - 35.📦 In the box model, which part is the line round the box? (a) padding (b) content (c) margin (d) border
- 36.🎨 Which attribute adds CSS inside one tag? (a) style (b) alt (c) href (d) src
- 37.Which of these does JavaScript do? (a) makes headings and lists (b) makes a form box (c) shows a pop-up message (d) adds space around boxes
- 38.🧩 Which language changes the text size? (a) CSS (b) HTML (c) JavaScript
-
39.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 130px;
padding: 20px;
border: 5px solid black;
margin: 0px;
} - 40.What does font-weight do? (a) makes the text bold (b) centres a heading (c) sets the letter colour (d) picks the font style
Answer key
- yellow
- .box
- adds space around boxes
- reacts to a button click
- h1
- 60
- blue
- an id selector
- yellow
- red
- italic
- padding
- 16
- blue
- 80
- :
- orange
- bright green
- #main
- black
- False
- yellow
- 220
- JavaScript
- align-items
- font-family
- .note
- magenta
- 344
- justify-content
- 198
- an element selector
- No
- yellow
- border
- style
- shows a pop-up message
- CSS
- 180
- makes the text bold
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids