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