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