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 is the selector in this CSS rule?
body {
font-style: italic;
color: red;
} (a) red (b) .box (c) body (d) font-style -
2.📱 The screen is 540px wide. Does the rule inside @media apply?
p {
font-size: 12px;
}
@media (max-width: 1024px) {
p {
font-size: 8px;
}
} (a) Yes (b) No - 3.Which of these is the border? (a) space inside the border (b) the gap round content (c) a solid or dotted edge (d) space outside the border
- 4.🎯 Which element does the selector #logo style? (a) <h1 class="big"> (b) <p id="logo"> (c) <p id="end"> (d) <p class="logo">
- 5.🎨 Which tag connects an outside CSS file? (a) <css> (b) <img> (c) <link> (d) <a>
- 6.Which of these is the content? (a) space inside the border (b) the gap to other boxes (c) space outside the border (d) the text or picture
- 7.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) 800px or narrower (c) exactly 100px (d) 800px or wider
- 8.🌈 Which colour of light is strongest in rgb(127, 37, 255)? (a) red (b) blue (c) green
- 9.🎯 Can many elements share the same class? (a) No (b) Yes
- 10.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 4 (b) 3 (c) 2 (d) 6
- 11.🎯 What kind of selector is #hero? (a) an id selector (b) an element selector (c) a class selector
-
12.🖌️ What colour are the letters?
h2 {
font-size: 24px;
text-align: center;
color: black;
background-color: red;
} (a) red (b) blue (c) black -
13.⚖️ What colour is the text of this element?
<h1 class="star" id="hero">Hi</h1>
CSS:
h1 { color: black; }
h1 { color: red; } (a) orange (b) red (c) black (d) blue -
14.✍️ What is the selector in this CSS rule?
h2 {
margin: 10px;
font-weight: bold;
} (a) margin (b) h2 (c) bold (d) h1 - 15.Which of these does JavaScript do? (a) makes a link (b) sets colours and fonts (c) makes headings and lists (d) reacts to a button click
- 16.🌈 Which hex code is red? (a) #ffff00 (b) #ff00ff (c) #00ffff (d) #ff0000
- 17.True or false: body is a class selector. (a) False (b) True
-
18.💪 How much empty space (px) is left after the last box?
.row {
display: flex;
width: 330px;
justify-content: flex-start;
}
Inside are 4 boxes, each 80px wide (no margins). -
19.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 160px;
padding: 15px;
border: 1px solid black;
margin: 0px;
} -
20.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
p {
font-size: 16px;
}
@media (max-width: 480px) {
p {
font-size: 14px;
}
} - 21.🧩 Which language lays out the page? (a) JavaScript (b) CSS (c) HTML
-
22.🖌️ What colour are the letters?
h2 {
color: yellow;
text-align: left;
background-color: blue;
font-size: 40px;
} (a) purple (b) yellow (c) blue - 23.True or false: CSS makes headings and lists. (a) True (b) False
-
24.✍️ How many declarations (property: value pairs) are in this rule?
li {
width: 300px;
font-style: italic;
text-align: center;
} -
25.🖌️ What colour is behind the letters?
h2 {
text-align: center;
color: black;
background-color: purple;
font-size: 32px;
} (a) orange (b) black (c) purple -
26.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
.box {
width: 200px;
padding: 25px;
border: 5px solid black;
margin: 15px;
} - 27.💪 Which justify-content value packs boxes at the start? (a) flex-start (b) center (c) space-between (d) flex-end
- 28.True or false: the border is a solid or dotted edge. (a) False (b) True
- 29.🧩 Which language changes the page live? (a) CSS (b) HTML (c) JavaScript
-
30.⚖️ What colour is the text of this element?
<h2 class="box" id="end">Hi</h2>
CSS:
#end { color: white; }
#end { color: blue; } (a) white (b) purple (c) blue (d) red - 31.🎯 Which element does the selector #top style? (a) <h2 class="top"> (b) <h2 id="top"> (c) <li class="note"> (d) <h2 id="intro">
- 32.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) black (c) blue (d) red
- 33.🌈 Which colour is #ff00ff? (a) black (b) magenta (c) red (d) blue
- 34.✍️ CSS declarations go inside which brackets? (a) [ ] (b) < > (c) ( ) (d) { }
- 35.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
- 36.🖌️ Which CSS property colours behind the text? (a) font-weight (b) font-family (c) text-align (d) background-color
- 37.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the br tag (c) the viewport meta tag (d) the title tag
-
38.🖌️ What colour is behind the letters?
h1 {
background-color: blue;
text-align: center;
color: orange;
font-size: 36px;
} (a) orange (b) green (c) blue - 39.True or false: the content is the line round the box. (a) False (b) True
- 40.✍️ In color: blue; which part is the value? (a) blue (b) color (c) : (d) ;
Answer key
- body
- Yes
- a solid or dotted edge
- <p id="logo">
- <link>
- the text or picture
- 800px or wider
- blue
- Yes
- 3
- an id selector
- black
- red
- h2
- reacts to a button click
- #ff0000
- False
- 10
- 192
- 16
- CSS
- yellow
- False
- 3
- purple
- 260
- flex-start
- True
- JavaScript
- blue
- <h2 id="top">
- red
- magenta
- { }
- an id selector
- background-color
- the viewport meta tag
- blue
- False
- blue
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids