← Selectors: element, class and id lesson New set →

CSS Worksheet: Selectors Class and Id

HTML and CSS lesson 13: Selectors: element, class and id · Set 995 · 40 questions
TalentJR

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

Answer key

  1. .red
  2. .note
  3. #
  4. <h2 id="hero">
  5. <h2 class="red">
  6. an element selector
  7. <p class="note">
  8. a class selector
  9. 1
  10. .red
  11. Yes
  12. True
  13. #intro
  14. <p id="end">
  15. False
  16. <h2 id="top">
  17. True
  18. <h1 class="note">
  19. <p id="intro">
  20. True
  21. .box
  22. p
  23. False
  24. True
  25. a class selector
  26. .note
  27. <span id="end">
  28. an element selector
  29. #main
  30. div
  31. False
  32. an id selector
  33. #logo
  34. False
  35. an element selector
  36. True
  37. <span class="red">
  38. .note
  39. #top
  40. h1

Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids