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

Answer key

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

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