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