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 flexbox property picks row or column? (a) display: flex (b) flex-direction (c) align-items (d) gap
-
2.⚖️ What colour is the text of this element?
<h2 class="star" id="hero">Hi</h2>
CSS:
#hero { color: red; }
h2 { color: green; } (a) black (b) green (c) white (d) red - 3.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) 800px or wider (c) exactly 100px (d) turned off
- 4.True or false: the content is the gap to other boxes. (a) False (b) True
- 5.🎨 One CSS file can style how many pages? (a) many pages (b) only one word (c) no pages (d) only one image
- 6.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
-
7.✍️ What value is given to font-size in this rule?
p {
font-size: 20px;
padding: 8px;
border: 2px solid;
} (a) center (b) font-size (c) 20px (d) yellow -
8.⚖️ What colour is the text of this element?
<p class="big" id="intro">Hi</p>
CSS:
.big { color: purple; }
#intro { color: green; } (a) blue (b) green (c) purple (d) red - 9.🌈 Hex digits go 0 to 9, then A to which letter? (a) F (b) G (c) J (d) Z
- 10.True or false: JavaScript checks a quiz answer. (a) False (b) True
- 11.🎯 How many elements on a page should have the same id? (a) 1 (b) 5 (c) any number (d) 2
- 12.🎯 Which element does the selector h1 style? (a) <h1 class="red"> (b) <h2> (c) <div id="top"> (d) <li class="red">
- 13.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the later one (b) the shorter one (c) neither (d) the first one
- 14.True or false: CSS rounds box corners. (a) False (b) True
- 15.What does justify-content: flex-end do? (a) equal gaps, none at ends (b) packs boxes at the end (c) packs boxes at the start (d) puts boxes in the middle
- 16.True or false: the border is the gap to other boxes. (a) True (b) False
- 17.📦 In the box model, which part is space outside the border? (a) padding (b) border (c) content (d) margin
- 18.🎯 What kind of selector is #hero? (a) an id selector (b) an element selector (c) a class selector
- 19.🧩 Which language rounds box corners? (a) JavaScript (b) HTML (c) CSS
- 20.Which of these does CSS do? (a) makes headings and lists (b) puts a picture on a page (c) sets colours and fonts (d) gives the page structure
-
21.📱 The screen is 1366px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 600px) {
p {
font-size: 8px;
}
} (a) Yes (b) No - 22.💪 Which flexbox property spaces boxes along a row? (a) align-items (b) display: flex (c) gap (d) justify-content
- 23.🎯 What kind of selector is #top? (a) an id selector (b) an element selector (c) a class selector
-
24.⚖️ What colour is the text of this element?
<h1 class="menu" id="intro">Hi</h1>
CSS:
#intro { color: yellow; }
#intro { color: white; } (a) green (b) white (c) purple (d) yellow -
25.🎯 Which CSS selector matches this element?
<div class="big" id="main">Hello</div> (a) #big (b) .red (c) div (d) #logo - 26.What does background-color do? (a) centres a heading (b) makes letters bigger (c) makes the text bold (d) colours behind the text
-
27.✍️ What is the selector in this CSS rule?
#top {
padding: 8px;
font-weight: bold;
margin: 10px;
} (a) bold (b) #top (c) li (d) padding - 28.📦 In the box model, which part is the gap round content? (a) padding (b) margin (c) border (d) content
- 29.💪 Which justify-content value packs boxes at the start? (a) center (b) space-between (c) flex-start (d) flex-end
- 30.🌈 Which hex code is magenta? (a) #ffffff (b) #ff00ff (c) #00ff00 (d) #ff0000
- 31.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or narrower (c) 600px or wider (d) turned off
- 32.🧩 Which language sets colours and fonts? (a) JavaScript (b) HTML (c) CSS
-
33.✍️ Which property is set to red in this rule?
h2 {
font-size: 20px;
color: red;
background-color: yellow;
} (a) text-align (b) font-size (c) red (d) color - 34.True or false: CSS makes a link. (a) True (b) False
-
35.✍️ What is the selector in this CSS rule?
#top {
margin: 10px;
color: red;
} (a) margin (b) #top (c) red (d) li -
36.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 280px;
padding: 30px;
border: 2px solid black;
margin: 0px;
} -
37.🖌️ How big is the text, in px?
h1 {
text-align: center;
font-size: 28px;
background-color: black;
color: white;
} -
38.✍️ What value is given to width in this rule?
#top {
font-size: 20px;
color: red;
width: 300px;
} (a) width (b) red (c) italic (d) 300px -
39.✍️ What value is given to font-weight in this rule?
li {
font-weight: bold;
width: 300px;
} (a) 300px (b) 2px solid (c) bold (d) font-weight - 40.🌈 Which hex code is blue? (a) #0000ff (b) #ffffff (c) #ff0000 (d) #ffff00
Answer key
- flex-direction
- red
- 800px or wider
- False
- many pages
- an id selector
- 20px
- green
- F
- True
- 1
- <h1 class="red">
- the later one
- True
- packs boxes at the end
- False
- margin
- an id selector
- CSS
- sets colours and fonts
- No
- justify-content
- an id selector
- white
- div
- colours behind the text
- #top
- padding
- flex-start
- #ff00ff
- 600px or narrower
- CSS
- color
- False
- #top
- 344
- 28
- 300px
- bold
- #0000ff
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids