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

Answer key

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

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