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

Answer key

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

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