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.✍️ What value is given to padding in this rule?
h2 {
font-size: 20px;
padding: 8px;
font-weight: bold;
text-align: center;
} (a) 2px solid (b) 8px (c) padding (d) bold - 2.🌈 Which colour is #ff0000? (a) red (b) blue (c) bright green (d) black
- 3.Which of these does HTML do? (a) changes the page live (b) makes a link (c) checks a quiz answer (d) reacts to a button click
-
4.⚖️ What colour is the text of this element?
<h1 class="star" id="intro">Hi</h1>
CSS:
#intro { color: red; }
#intro { color: black; } (a) red (b) black (c) green (d) blue -
5.⚖️ What colour is the text of this element?
<p class="red" id="end">Hi</p>
CSS:
.red { color: blue; }
.red { color: green; } (a) yellow (b) green (c) blue (d) black - 6.True or false: padding is the gap round content. (a) False (b) True
- 7.🎯 Which sign starts an id selector? (a) # (b) & (c) . (d) @
- 8.💪 Which flexbox property spaces boxes along a row? (a) align-items (b) gap (c) justify-content (d) flex-direction
- 9.True or false: JavaScript gives the page structure. (a) False (b) True
- 10.🎯 Which sign starts a class selector? (a) @ (b) & (c) . (d) #
- 11.📱 What does a media query check? (a) the battery level (b) the page title (c) the screen width (d) the time of day
-
12.✍️ How many declarations (property: value pairs) are in this rule?
body {
color: red;
font-weight: bold;
background-color: yellow;
width: 300px;
} -
13.✍️ What value is given to font-style in this rule?
.note {
text-align: center;
font-style: italic;
} (a) 20px (b) red (c) font-style (d) italic -
14.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 300px;
justify-content: space-between;
}
Inside are 3 boxes, each 60px wide (no margins). - 15.🖌️ Which CSS property sets the letter colour? (a) color (b) background-color (c) text-align (d) font-family
- 16.🎯 How many elements on a page should have the same id? (a) 1 (b) any number (c) 5 (d) 2
-
17.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-size: 20px;
} -
18.✍️ What is the selector in this CSS rule?
h2 {
color: red;
border: 2px solid;
} (a) 2px solid (b) h1 (c) color (d) h2 -
19.⚖️ What colour is the text of this element?
<h2 class="menu" id="main">Hi</h2>
CSS:
.menu { color: green; }
h2 { color: white; } (a) red (b) yellow (c) green (d) white - 20.True or false: the border is space outside the border. (a) True (b) False
-
21.🎯 Which CSS selector matches this element?
<li class="box" id="intro">Hello</li> (a) #box (b) .intro (c) div (d) .box - 22.📱 Responsive design means a page ___. (a) fits every screen (b) has no pictures (c) never changes (d) is only for laptops
-
23.⚖️ What colour is the text of this element?
<p class="note" id="top">Hi</p>
CSS:
p { color: green; }
.note { color: blue; } (a) green (b) black (c) yellow (d) blue - 24.True or false: margin is space outside the border. (a) True (b) False
- 25.🎯 Which element does the selector #top style? (a) <div class="top"> (b) <div id="intro"> (c) <span class="red"> (d) <div id="top">
- 26.🎯 Which element does the selector li style? (a) <span class="red"> (b) <li class="red"> (c) <div> (d) <p id="hero">
- 27.✍️ In color: blue; which part is the value? (a) : (b) blue (c) color (d) ;
-
28.🖌️ What colour are the letters?
li {
text-align: left;
color: white;
background-color: yellow;
font-size: 12px;
} (a) white (b) red (c) yellow -
29.✍️ How many declarations (property: value pairs) are in this rule?
.note {
font-style: italic;
color: red;
} - 30.✍️ CSS declarations go inside which brackets? (a) [ ] (b) { } (c) ( ) (d) < >
- 31.True or false: #logo is a class selector. (a) False (b) True
-
32.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
p {
font-size: 24px;
}
@media (max-width: 480px) {
p {
font-size: 18px;
}
} -
33.🖌️ What colour is behind the letters?
li {
background-color: white;
font-size: 36px;
color: green;
text-align: right;
} (a) green (b) white (c) red -
34.✍️ How many declarations (property: value pairs) are in this rule?
p {
background-color: yellow;
font-weight: bold;
font-size: 20px;
} - 35.🎯 Which element does the selector p style? (a) <p class="note"> (b) <h1> (c) <h2 class="note"> (d) <li id="intro">
- 36.📦 In the box model, which part is the gap round content? (a) content (b) border (c) padding (d) margin
- 37.True or false: the border is the gap to other boxes. (a) True (b) False
-
38.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
color: red;
font-style: italic;
width: 300px;
} - 39.🌈 Which hex code is white? (a) #ff00ff (b) #ffffff (c) #ff0000 (d) #0000ff
- 40.What does text-align do? (a) picks the font style (b) makes the text bold (c) sets the letter colour (d) centres a heading
Answer key
- 8px
- red
- makes a link
- black
- green
- True
- #
- justify-content
- False
- .
- the screen width
- 4
- italic
- 60
- color
- 1
- 1
- h2
- green
- False
- .box
- fits every screen
- blue
- True
- <div id="top">
- <li class="red">
- blue
- white
- 2
- { }
- False
- 24
- white
- 3
- <p class="note">
- padding
- False
- 3
- #ffffff
- centres a heading
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids