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.📦 In the box model, which part is the line round the box? (a) margin (b) content (c) border (d) padding
-
2.✍️ Which property is set to center in this rule?
h2 {
font-size: 20px;
text-align: center;
} (a) center (b) background-color (c) margin (d) text-align -
3.🖌️ Where does the text sit on its line?
p {
color: purple;
text-align: right;
font-size: 20px;
background-color: black;
} (a) on the right (b) on the left (c) in the middle - 4.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the first one (c) neither (d) the later one
- 5.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
- 6.🌈 Which colour is rgb(255, 255, 0)? (a) white (b) yellow (c) cyan (d) magenta
- 7.🎯 Which element does the selector h1 style? (a) <h2> (b) <h1 class="menu"> (c) <li class="menu"> (d) <div id="intro">
-
8.✍️ What is the selector in this CSS rule?
li {
margin: 10px;
border: 2px solid;
} (a) margin (b) li (c) 2px solid (d) body - 9.🎨 Which tag holds CSS inside the head? (a) <style> (b) <body> (c) <css> (d) <script>
-
10.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 280px;
justify-content: space-between;
}
Inside are 4 boxes, each 40px wide (no margins). - 11.✍️ Which sign ends each CSS declaration? (a) . (b) : (c) , (d) ;
- 12.✍️ In color: blue; which part is the value? (a) blue (b) color (c) ; (d) :
- 13.💪 Which flexbox property picks row or column? (a) display: flex (b) gap (c) justify-content (d) flex-direction
- 14.💪 Which justify-content value equal gaps, none at ends? (a) flex-start (b) center (c) flex-end (d) space-between
-
15.🖌️ Where does the text sit on its line?
h1 {
font-size: 20px;
background-color: white;
text-align: right;
color: red;
} (a) in the middle (b) on the left (c) on the right -
16.⚖️ What colour is the text of this element?
<h1 class="menu" id="logo">Hi</h1>
CSS:
h1 { color: yellow; }
h1 { color: black; } (a) yellow (b) white (c) red (d) black - 17.True or false: padding is space outside the border. (a) False (b) True
- 18.🌈 What is the biggest number one colour can have in rgb()? (a) 255 (b) 1000 (c) 100 (d) 99
-
19.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 90px;
padding: 25px;
border: 5px solid black;
margin: 0px;
} - 20.✍️ How does a CSS comment start? (a) /* (b) <!-- (c) # (d) //
- 21.What does justify-content: center do? (a) puts boxes in the middle (b) equal gaps, none at ends (c) packs boxes at the start (d) packs boxes at the end
- 22.🧩 Which language reacts to a button click? (a) HTML (b) CSS (c) JavaScript
-
23.🎯 Which CSS selector matches this element?
<h1 class="note" id="intro">Hello</h1> (a) h1 (b) #main (c) .intro (d) #note -
24.✍️ Which property is set to 10px in this rule?
p {
font-weight: bold;
font-size: 20px;
color: red;
margin: 10px;
} (a) padding (b) font-weight (c) 10px (d) margin - 25.🔍 Which is the odd one out? (a) counts down a timer (b) reacts to a button click (c) changes the page live (d) makes a link
- 26.Which of these is margin? (a) space inside the border (b) space outside the border (c) the gap round content (d) the text or picture
- 27.🧩 Which language shows a pop-up message? (a) JavaScript (b) HTML (c) CSS
- 28.🧩 Which language checks a quiz answer? (a) JavaScript (b) CSS (c) HTML
-
29.🖌️ How big is the text, in px?
h2 {
color: black;
background-color: purple;
font-size: 32px;
text-align: right;
} - 30.🎯 Can many elements share the same class? (a) Yes (b) No
- 31.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
- 32.🎯 Which element does the selector .star style? (a) <h1 class="star"> (b) <h2 class="note"> (c) <h1 id="star"> (d) <h1 class="menu">
- 33.📦 In the box model, which part is space outside the border? (a) margin (b) padding (c) content (d) border
- 34.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the br tag (c) the title tag (d) the viewport meta tag
- 35.✍️ In color: blue; which part is the property? (a) blue (b) ; (c) : (d) color
- 36.🎯 Which element does the selector #end style? (a) <p class="end"> (b) <p id="hero"> (c) <h1 class="box"> (d) <p id="end">
-
37.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 190px;
padding: 30px;
border: 1px solid black;
margin: 0px;
} - 38.🎯 Which sign starts a class selector? (a) . (b) @ (c) & (d) #
-
39.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 600px) {
p {
font-size: 18px;
}
} (a) Yes (b) No - 40.True or false: padding is the text or picture. (a) True (b) False
Answer key
- border
- text-align
- on the right
- the later one
- an element selector
- yellow
- <h1 class="menu">
- li
- <style>
- 40
- ;
- blue
- flex-direction
- space-between
- on the right
- black
- False
- 255
- 150
- /*
- puts boxes in the middle
- JavaScript
- h1
- margin
- makes a link
- space outside the border
- JavaScript
- JavaScript
- 32
- Yes
- an id selector
- <h1 class="star">
- margin
- the viewport meta tag
- color
- <p id="end">
- 252
- .
- Yes
- False
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids