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