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