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 tag helps phones show a page at the right size? (a) the viewport meta tag (b) the hr tag (c) the br tag (d) the title tag
-
2.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 240px;
justify-content: flex-end;
}
Inside are 4 boxes, each 40px wide (no margins). -
3.✍️ How many declarations (property: value pairs) are in this rule?
body {
border: 2px solid;
} - 4.💪 Which justify-content value packs boxes at the start? (a) flex-start (b) space-between (c) flex-end (d) center
-
5.✍️ How many declarations (property: value pairs) are in this rule?
li {
margin: 10px;
} -
6.📱 The screen is 820px wide. Does the rule inside @media apply?
p {
font-size: 20px;
}
@media (min-width: 1024px) {
p {
font-size: 26px;
}
} (a) No (b) Yes - 7.True or false: the content is space inside the border. (a) False (b) True
-
8.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 50px;
padding: 5px;
border: 4px solid black;
margin: 5px;
} - 9.✍️ In color: blue; which part is the value? (a) : (b) blue (c) color (d) ;
-
10.🎯 Which CSS selector matches this element?
<h2 class="menu" id="hero">Hello</h2> (a) #menu (b) #top (c) h2 (d) .note -
11.⚖️ What colour is the text of this element?
<h1 class="menu" id="intro">Hi</h1>
CSS:
.menu { color: yellow; }
h1 { color: red; } (a) black (b) yellow (c) red (d) blue -
12.🖌️ What colour are the letters?
h1 {
font-size: 28px;
background-color: black;
text-align: right;
color: purple;
} (a) purple (b) green (c) black - 13.🎯 How many elements on a page should have the same id? (a) any number (b) 2 (c) 1 (d) 5
- 14.✍️ Which sign ends each CSS declaration? (a) ; (b) , (c) . (d) :
-
15.⚖️ What colour is the text of this element?
<p class="big" id="intro">Hi</p>
CSS:
.big { color: orange; }
.big { color: blue; } (a) red (b) yellow (c) orange (d) blue - 16.🌈 In #ba0000 the red part is the hex number ba. What is it as a normal number?
- 17.Which of these is margin? (a) the gap to other boxes (b) the gap round content (c) a solid or dotted edge (d) space inside the border
- 18.🎨 Which attribute adds CSS inside one tag? (a) style (b) alt (c) src (d) href
- 19.📦 In the box model, which part is the gap round content? (a) content (b) border (c) padding (d) margin
- 20.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
-
21.⚖️ What colour is the text of this element?
<h1 class="menu" id="hero">Hi</h1>
CSS:
#hero { color: black; }
#hero { color: purple; } (a) green (b) purple (c) black (d) orange -
22.⚖️ What colour is the text of this element?
<h2 class="red" id="hero">Hi</h2>
CSS:
#hero { color: blue; }
#hero { color: red; } (a) red (b) white (c) blue (d) green -
23.🖌️ What colour is behind the letters?
li {
font-size: 24px;
background-color: white;
color: yellow;
text-align: left;
} (a) blue (b) yellow (c) white -
24.✍️ How many declarations (property: value pairs) are in this rule?
.note {
background-color: yellow;
width: 300px;
padding: 8px;
} -
25.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 120px;
padding: 5px;
border: 3px solid black;
margin: 0px;
} - 26.🧩 Which language rounds box corners? (a) CSS (b) JavaScript (c) HTML
-
27.⚖️ What colour is the text of this element?
<h2 class="box" id="top">Hi</h2>
CSS:
#top { color: orange; }
.box { color: white; } (a) orange (b) green (c) purple (d) white - 28.✍️ In color: blue; which part is the property? (a) : (b) blue (c) ; (d) color
-
29.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (min-width: 480px) {
p {
font-size: 26px;
}
} (a) No (b) Yes -
30.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 60px;
padding: 25px;
border: 4px solid black;
margin: 5px;
} - 31.🌈 In #040000 the red part is the hex number 04. What is it as a normal number?
-
32.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
p {
font-size: 12px;
}
@media (min-width: 600px) {
p {
font-size: 14px;
}
} - 33.🌈 Which colour is #ff0000? (a) blue (b) black (c) red (d) bright green
- 34.✍️ CSS declarations go inside which brackets? (a) < > (b) ( ) (c) [ ] (d) { }
- 35.🌈 Which hex code is bright green? (a) #ff0000 (b) #0000ff (c) #00ff00 (d) #ffff00
-
36.⚖️ What colour is the text of this element?
<h1 class="big" id="hero">Hi</h1>
CSS:
#hero { color: black; }
h1 { color: yellow; } (a) orange (b) yellow (c) black (d) white - 37.📱 min-width: 800px applies when the screen is ___. (a) exactly 100px (b) 800px or wider (c) turned off (d) 800px or narrower
-
38.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 110px;
padding: 5px;
border: 4px solid black;
margin: 0px;
} -
39.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 280px;
justify-content: center;
}
Inside are 3 boxes, each 40px wide (no margins). - 40.True or false: .star is a class selector. (a) True (b) False
Answer key
- the viewport meta tag
- 80
- 1
- flex-start
- 1
- No
- False
- 68
- blue
- h2
- yellow
- purple
- 1
- ;
- blue
- 186
- the gap to other boxes
- style
- padding
- an id selector
- purple
- red
- white
- 3
- 136
- CSS
- orange
- color
- Yes
- 128
- 4
- 12
- red
- { }
- #00ff00
- black
- 800px or wider
- 128
- 80
- True
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids