CSS Worksheet: Selectors Class and Id
Code tip (Dot for class, hash for id): p matches every <p>; .note matches class="note"; #top matches id="top". A dot means class, a hash means id — mixing them up matches nothing. Many elements can share a class; an id belongs to only one element.
NameDateTime takenScore ___ / 40
- 1.🎯 Which sign starts a class selector? (a) & (b) # (c) @ (d) .
- 2.🎯 Which element does the selector #end style? (a) <div class="end"> (b) <div id="end"> (c) <span class="red"> (d) <div id="hero">
- 3.🎯 Can many elements share the same class? (a) Yes (b) No
- 4.🎯 How many elements on a page should have the same id? (a) any number (b) 5 (c) 2 (d) 1
- 5.🎯 What kind of selector is li? (a) a class selector (b) an id selector (c) an element selector
- 6.🎯 What kind of selector is #logo? (a) an element selector (b) a class selector (c) an id selector
- 7.True or false: img is an element selector. (a) False (b) True
- 8.🎯 What kind of selector is .card? (a) an id selector (b) a class selector (c) an element selector
- 9.🎯 What kind of selector is #end? (a) an id selector (b) a class selector (c) an element selector
- 10.True or false: body is a class selector. (a) True (b) False
- 11.True or false: #end is an element selector. (a) False (b) True
- 12.🎯 Which element does the selector li style? (a) <div> (b) <span class="red"> (c) <li class="red"> (d) <p id="end">
-
13.🎯 Which CSS selector matches this element?
<h2 class="big" id="hero">Hello</h2> (a) h2 (b) #big (c) .hero (d) .red -
14.🎯 Which CSS selector matches this element?
<h2 class="red" id="main">Hello</h2> (a) #red (b) h2 (c) .box (d) .main - 15.🎯 What kind of selector is .star? (a) an element selector (b) a class selector (c) an id selector
- 16.True or false: .card is a class selector. (a) False (b) True
-
17.🎯 Which CSS selector matches this element?
<span class="box" id="top">Hello</span> (a) .box (b) .star (c) #box (d) p - 18.🎯 Which element does the selector #main style? (a) <p class="note"> (b) <span id="logo"> (c) <span class="main"> (d) <span id="main">
- 19.🎯 What kind of selector is img? (a) a class selector (b) an id selector (c) an element selector
- 20.True or false: #logo is an element selector. (a) True (b) False
- 21.🎯 Which sign starts an id selector? (a) @ (b) . (c) & (d) #
-
22.🎯 Which CSS selector matches this element?
<li class="star" id="main">Hello</li> (a) .main (b) li (c) div (d) #logo -
23.🎯 Which CSS selector matches this element?
<div class="note" id="top">Hello</div> (a) .note (b) #intro (c) #note (d) .top - 24.🎯 Which element does the selector .big style? (a) <p class="box"> (b) <span class="big"> (c) <span id="big"> (d) <span class="red">
-
25.🎯 Which CSS selector matches this element?
<div class="big" id="end">Hello</div> (a) span (b) #hero (c) #end (d) #big -
26.🎯 Which CSS selector matches this element?
<h1 class="note" id="hero">Hello</h1> (a) #top (b) .big (c) h1 (d) .hero - 27.🎯 What kind of selector is #main? (a) an element selector (b) an id selector (c) a class selector
- 28.True or false: .star is a class selector. (a) True (b) False
-
29.🎯 Which CSS selector matches this element?
<p class="red" id="main">Hello</p> (a) #red (b) .main (c) #logo (d) .red -
30.🎯 Which CSS selector matches this element?
<span class="menu" id="top">Hello</span> (a) .top (b) span (c) #menu (d) p - 31.🎯 What kind of selector is p? (a) a class selector (b) an element selector (c) an id selector
-
32.🎯 Which CSS selector matches this element?
<p class="red" id="logo">Hello</p> (a) p (b) #end (c) .box (d) #red - 33.🎯 Which element does the selector .red style? (a) <li class="red"> (b) <div class="star"> (c) <li id="red"> (d) <li class="box">
- 34.🎯 Which element does the selector #top style? (a) <li id="top"> (b) <div class="big"> (c) <li id="intro"> (d) <li class="top">
-
35.🎯 Which CSS selector matches this element?
<p class="box" id="top">Hello</p> (a) #box (b) #intro (c) h1 (d) #top -
36.🎯 Which CSS selector matches this element?
<p class="note" id="main">Hello</p> (a) .big (b) #main (c) #logo (d) .main -
37.🎯 Which CSS selector matches this element?
<div class="red" id="hero">Hello</div> (a) div (b) #top (c) #red (d) .hero - 38.🎯 What kind of selector is h1? (a) an element selector (b) an id selector (c) a class selector
- 39.True or false: .big is an element selector. (a) True (b) False
- 40.🎯 Which element does the selector #main style? (a) <li id="main"> (b) <li class="main"> (c) <li id="logo"> (d) <div class="note">
Answer key
- .
- <div id="end">
- Yes
- 1
- an element selector
- an id selector
- True
- a class selector
- an id selector
- False
- False
- <li class="red">
- h2
- h2
- a class selector
- True
- .box
- <span id="main">
- an element selector
- False
- #
- li
- .note
- <span class="big">
- #end
- h1
- an id selector
- True
- .red
- span
- an element selector
- p
- <li class="red">
- <li id="top">
- #top
- #main
- div
- an element selector
- False
- <li id="main">
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids