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.True or false: #end is an element selector. (a) False (b) True
- 2.Which of these does CSS do? (a) lays out the page (b) shows a pop-up message (c) gives the page structure (d) puts a picture on a page
- 3.True or false: padding is space inside the border. (a) False (b) True
-
4.🖌️ What colour are the letters?
h2 {
text-align: center;
background-color: green;
font-size: 36px;
color: purple;
} (a) purple (b) black (c) green - 5.✍️ How does a CSS comment start? (a) /* (b) // (c) # (d) <!--
-
6.✍️ Which property is set to 10px in this rule?
h1 {
margin: 10px;
font-size: 20px;
} (a) font-weight (b) margin (c) padding (d) 10px - 7.🌈 Which colour is #00ffff? (a) red (b) white (c) magenta (d) cyan
- 8.True or false: .big is an id selector. (a) False (b) True
-
9.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 190px;
padding: 25px;
border: 2px solid black;
margin: 10px;
} - 10.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the later one (c) the shorter one (d) neither
- 11.🎯 Which sign starts an id selector? (a) # (b) @ (c) . (d) &
- 12.Which of these is padding? (a) a solid or dotted edge (b) space outside the border (c) the line round the box (d) space inside the border
- 13.🌈 Which colour is rgb(255, 255, 0)? (a) white (b) yellow (c) black (d) bright green
-
14.✍️ What value is given to padding in this rule?
p {
font-size: 20px;
padding: 8px;
text-align: center;
} (a) 8px (b) padding (c) 2px solid (d) bold - 15.🎯 Which element does the selector #end style? (a) <h2 id="end"> (b) <h2 id="hero"> (c) <li class="star"> (d) <h2 class="end">
-
16.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 768px) {
p {
font-size: 18px;
}
} -
17.✍️ How many declarations (property: value pairs) are in this rule?
li {
font-weight: bold;
padding: 8px;
font-size: 20px;
border: 2px solid;
} -
18.✍️ Which property is set to 2px solid in this rule?
body {
border: 2px solid;
font-weight: bold;
} (a) 2px solid (b) font-style (c) width (d) border - 19.🌈 Which colour is rgb(0, 0, 255)? (a) magenta (b) black (c) white (d) blue
-
20.⚖️ What colour is the text of this element?
<p class="menu" id="logo">Hi</p>
CSS:
#logo { color: white; }
#logo { color: orange; } (a) orange (b) white (c) blue (d) red - 21.✍️ CSS declarations go inside which brackets? (a) [ ] (b) { } (c) < > (d) ( )
- 22.True or false: HTML puts a picture on a page. (a) True (b) False
- 23.🌈 Which colour is #ffff00? (a) white (b) magenta (c) yellow (d) blue
- 24.Which of these does CSS do? (a) makes a link (b) adds space around boxes (c) makes a form box (d) makes headings and lists
-
25.🖌️ What colour are the letters?
p {
text-align: center;
background-color: green;
color: black;
font-size: 12px;
} (a) green (b) black (c) orange - 26.🔍 Which is the odd one out? (a) makes a form box (b) gives the page structure (c) puts a picture on a page (d) changes the page live
-
27.🖌️ Where does the text sit on its line?
h1 {
color: red;
font-size: 16px;
background-color: black;
text-align: left;
} (a) in the middle (b) on the left (c) on the right -
28.🎯 Which CSS selector matches this element?
<h2 class="red" id="logo">Hello</h2> (a) #red (b) .logo (c) li (d) h2 -
29.🖌️ Where does the text sit on its line?
p {
font-size: 20px;
background-color: yellow;
color: orange;
text-align: right;
} (a) on the left (b) on the right (c) in the middle -
30.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 80px;
padding: 30px;
border: 3px solid black;
margin: 15px;
} -
31.⚖️ What colour is the text of this element?
<p class="star" id="top">Hi</p>
CSS:
p { color: red; }
p { color: white; } (a) blue (b) red (c) white (d) black -
32.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 400px;
justify-content: flex-end;
}
Inside are 4 boxes, each 80px wide (no margins). -
33.✍️ How many declarations (property: value pairs) are in this rule?
#top {
font-style: italic;
} -
34.🎯 Which CSS selector matches this element?
<h1 class="big" id="intro">Hello</h1> (a) h2 (b) #big (c) .intro (d) .big - 35.🎯 What kind of selector is p? (a) an element selector (b) an id selector (c) a class selector
- 36.🧩 Which language lays out the page? (a) CSS (b) HTML (c) JavaScript
-
37.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 120px;
padding: 10px;
border: 4px solid black;
margin: 20px;
} -
38.⚖️ What colour is the text of this element?
<h1 class="menu" id="intro">Hi</h1>
CSS:
#intro { color: yellow; }
#intro { color: orange; } (a) orange (b) yellow (c) black (d) purple - 39.🎯 Which element does the selector p style? (a) <h2 class="big"> (b) <li id="logo"> (c) <h1> (d) <p class="big">
-
40.✍️ What is the selector in this CSS rule?
.note {
font-size: 20px;
margin: 10px;
font-weight: bold;
} (a) 10px (b) font-size (c) #top (d) .note
Answer key
- False
- lays out the page
- True
- purple
- /*
- margin
- cyan
- False
- 264
- the later one
- #
- space inside the border
- yellow
- 8px
- <h2 id="end">
- 24
- 4
- border
- blue
- orange
- { }
- True
- yellow
- adds space around boxes
- black
- changes the page live
- on the left
- h2
- on the right
- 176
- white
- 80
- 1
- .big
- an element selector
- CSS
- 188
- orange
- <p class="big">
- .note
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids