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