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