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

Answer key

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

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