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