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