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 of these is the content? (a) a solid or dotted edge (b) the text or picture (c) space inside the border (d) the gap to other boxes
- 2.🌈 In #rrggbb, which colour do the first two digits give? (a) blue (b) green (c) black (d) red
- 3.🌈 Which hex code is yellow? (a) #00ffff (b) #ffff00 (c) #00ff00 (d) #ff0000
- 4.🔍 Which is the odd one out? (a) sets colours and fonts (b) gives the page structure (c) rounds box corners (d) adds space around boxes
-
5.⚖️ What colour is the text of this element?
<h1 class="big" id="hero">Hi</h1>
CSS:
h1 { color: blue; }
h1 { color: red; } (a) red (b) purple (c) blue (d) orange -
6.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 40px;
padding: 25px;
border: 1px solid black;
margin: 20px;
} - 7.📱 Responsive design means a page ___. (a) never changes (b) is only for laptops (c) fits every screen (d) has no pictures
- 8.🌈 Which colour of light is strongest in rgb(30, 227, 84)? (a) red (b) blue (c) green
-
9.✍️ What value is given to padding in this rule?
li {
font-weight: bold;
color: red;
padding: 8px;
} (a) 2px solid (b) 8px (c) padding (d) bold - 10.True or false: HTML makes headings and lists. (a) True (b) False
- 11.🎨 What does CSS stand for? (a) Cascading Style Sheets (b) Colourful Site Styles (c) Computer Style Sheets (d) Creative Sheet System
- 12.What does font-family do? (a) centres a heading (b) makes the text bold (c) colours behind the text (d) picks the font style
- 13.Which of these is margin? (a) the gap to other boxes (b) a solid or dotted edge (c) the text or picture (d) the line round the box
-
14.🖌️ How big is the text, in px?
h1 {
text-align: center;
color: yellow;
font-size: 20px;
background-color: red;
} - 15.🎨 Which attribute adds CSS inside one tag? (a) style (b) src (c) href (d) alt
- 16.🔍 Which is the odd one out? (a) changes the text size (b) sets colours and fonts (c) lays out the page (d) makes headings and lists
-
17.🖌️ Where does the text sit on its line?
p {
color: yellow;
text-align: left;
font-size: 24px;
background-color: white;
} (a) on the left (b) on the right (c) in the middle -
18.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 24px;
}
@media (max-width: 1024px) {
p {
font-size: 20px;
}
} (a) No (b) Yes - 19.✍️ In color: blue; which part is the value? (a) color (b) blue (c) : (d) ;
-
20.⚖️ What colour is the text of this element?
<h2 class="big" id="top">Hi</h2>
CSS:
#top { color: purple; }
h2 { color: black; }
.big { color: red; } (a) blue (b) black (c) red (d) purple - 21.🌈 Which hex code is white? (a) #ffff00 (b) #ff0000 (c) #ffffff (d) #0000ff
-
22.✍️ What value is given to color in this rule?
#top {
text-align: center;
color: red;
} (a) center (b) 20px (c) red (d) color - 23.🌈 Which colour of light is strongest in rgb(45, 238, 34)? (a) red (b) green (c) blue
- 24.🎯 What kind of selector is .card? (a) an element selector (b) a class selector (c) an id selector
-
25.✍️ How many declarations (property: value pairs) are in this rule?
li {
padding: 8px;
border: 2px solid;
} -
26.⚖️ What colour is the text of this element?
<h1 class="menu" id="top">Hi</h1>
CSS:
h1 { color: red; }
#top { color: yellow; } (a) orange (b) red (c) green (d) yellow -
27.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 260px;
padding: 25px;
border: 5px solid black;
margin: 0px;
} - 28.🎯 What kind of selector is p? (a) a class selector (b) an id selector (c) an element selector
-
29.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 1024px) {
p {
font-size: 10px;
}
} - 30.True or false: padding is the gap round content. (a) True (b) False
- 31.🧩 Which language reacts to a button click? (a) HTML (b) JavaScript (c) CSS
-
32.🖌️ Where does the text sit on its line?
p {
text-align: left;
color: purple;
background-color: blue;
font-size: 16px;
} (a) in the middle (b) on the right (c) on the left - 33.True or false: .menu is an id selector. (a) True (b) False
-
34.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 550px;
justify-content: space-between;
}
Inside are 4 boxes, each 100px wide (no margins). -
35.⚖️ What colour is the text of this element?
<h1 class="menu" id="intro">Hi</h1>
CSS:
.menu { color: purple; }
.menu { color: orange; } (a) orange (b) purple (c) red (d) white -
36.⚖️ What colour is the text of this element?
<p class="red" id="end">Hi</p>
CSS:
p { color: purple; }
.red { color: white; }
#end { color: black; } (a) black (b) purple (c) red (d) white -
37.💪 How much empty space (px) is before the first box?
.row {
display: flex;
width: 270px;
justify-content: flex-end;
}
Inside are 2 boxes, each 100px wide (no margins). - 38.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
- 39.What does font-size do? (a) sets the letter colour (b) picks the font style (c) centres a heading (d) makes letters bigger
- 40.✍️ CSS declarations go inside which brackets? (a) < > (b) { } (c) ( ) (d) [ ]
Answer key
- the text or picture
- red
- #ffff00
- gives the page structure
- red
- 132
- fits every screen
- green
- 8px
- True
- Cascading Style Sheets
- picks the font style
- the gap to other boxes
- 20
- style
- makes headings and lists
- on the left
- Yes
- blue
- purple
- #ffffff
- red
- green
- a class selector
- 2
- yellow
- 320
- an element selector
- 10
- True
- JavaScript
- on the left
- False
- 50
- orange
- black
- 70
- packs boxes at the end
- makes letters bigger
- { }
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids