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