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