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