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 selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
- 2.🖌️ Which CSS property sets the letter colour? (a) color (b) font-size (c) background-color (d) text-align
-
3.🖌️ What colour are the letters?
h2 {
background-color: blue;
text-align: center;
font-size: 24px;
color: yellow;
} (a) purple (b) yellow (c) blue - 4.✍️ How does a CSS comment start? (a) // (b) # (c) <!-- (d) /*
- 5.Which of these is the border? (a) the gap to other boxes (b) the gap round content (c) a solid or dotted edge (d) the text or picture
- 6.True or false: CSS reacts to a button click. (a) True (b) False
- 7.Which of these is padding? (a) space outside the border (b) a solid or dotted edge (c) space inside the border (d) the line round the box
- 8.🌈 In #rrggbb, which colour do the first two digits give? (a) black (b) blue (c) red (d) green
-
9.✍️ How many declarations (property: value pairs) are in this rule?
p {
border: 2px solid;
margin: 10px;
color: red;
} - 10.🌈 Which colour of light is strongest in rgb(108, 107, 237)? (a) red (b) blue (c) green
- 11.🧩 Which language changes the page live? (a) CSS (b) HTML (c) JavaScript
- 12.True or false: padding is the gap to other boxes. (a) True (b) False
-
13.🖌️ How big is the text, in px?
h1 {
font-size: 12px;
background-color: orange;
text-align: right;
color: purple;
} - 14.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) blue (c) white (d) red
-
15.💪 How wide (px) is each gap between two boxes?
.row {
display: flex;
width: 270px;
justify-content: space-between;
}
Inside are 2 boxes, each 100px wide (no margins). - 16.✍️ In color: blue; which part is the value? (a) ; (b) blue (c) color (d) :
- 17.🌈 In #cc0000 the red part is the hex number cc. What is it as a normal number?
- 18.📱 Which tag helps phones show a page at the right size? (a) the hr tag (b) the title tag (c) the viewport meta tag (d) the br tag
- 19.✍️ Which sign ends each CSS declaration? (a) , (b) ; (c) . (d) :
-
20.✍️ What value is given to background-color in this rule?
li {
font-style: italic;
background-color: yellow;
} (a) background-color (b) 10px (c) 8px (d) yellow - 21.What does justify-content: flex-start do? (a) packs boxes at the start (b) equal gaps, none at ends (c) packs boxes at the end (d) puts boxes in the middle
-
22.✍️ Which property is set to italic in this rule?
p {
font-style: italic;
margin: 10px;
width: 300px;
} (a) color (b) italic (c) font-size (d) font-style - 23.✍️ Which sign goes between a property and its value? (a) - (b) = (c) ; (d) :
- 24.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) exactly 1000px (c) turned off (d) 600px or narrower
- 25.🧩 Which language puts a picture on a page? (a) HTML (b) CSS (c) JavaScript
-
26.✍️ What value is given to color in this rule?
h1 {
margin: 10px;
color: red;
font-weight: bold;
} (a) center (b) 20px (c) red (d) color - 27.🌈 Which hex code is white? (a) #ff00ff (b) #ffffff (c) #00ffff (d) #00ff00
- 28.⚖️ 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
- 29.🎯 What kind of selector is #top? (a) an element selector (b) a class selector (c) an id selector
- 30.What does background-color do? (a) centres a heading (b) makes the text bold (c) colours behind the text (d) sets the letter colour
-
31.📦 How much space across (px) does this box take in all, margin included?
.box {
width: 290px;
padding: 30px;
border: 2px solid black;
margin: 0px;
} - 32.🌈 In #220000 the red part is the hex number 22. What is it as a normal number?
-
33.📦 How much space top to bottom (px) does this box take in all, margin included?
.box {
height: 60px;
padding: 20px;
border: 4px solid black;
margin: 0px;
} - 34.🌈 Which colour of light is strongest in rgb(3, 217, 21)? (a) red (b) green (c) blue
- 35.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
-
36.🎯 Which CSS selector matches this element?
<h2 class="star" id="main">Hello</h2> (a) #main (b) .main (c) .menu (d) #logo -
37.⚖️ What colour is the text of this element?
<h2 class="note" id="logo">Hi</h2>
CSS:
#logo { color: purple; }
h2 { color: yellow; } (a) blue (b) yellow (c) black (d) purple - 38.💪 Which flexbox property turns on flexbox? (a) flex-direction (b) align-items (c) justify-content (d) display: flex
- 39.🧩 Which language sets colours and fonts? (a) JavaScript (b) HTML (c) CSS
-
40.✍️ What value is given to font-style in this rule?
h2 {
font-weight: bold;
font-style: italic;
background-color: yellow;
} (a) font-style (b) italic (c) 20px (d) red
Answer key
- an id selector
- color
- yellow
- /*
- a solid or dotted edge
- False
- space inside the border
- red
- 3
- blue
- JavaScript
- False
- 12
- blue
- 70
- blue
- 204
- the viewport meta tag
- ;
- yellow
- packs boxes at the start
- font-style
- :
- 600px or narrower
- HTML
- red
- #ffffff
- the later one
- an id selector
- colours behind the text
- 354
- 34
- 108
- green
- an element selector
- #main
- purple
- display: flex
- CSS
- italic
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids