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

Answer key

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

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