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

Answer key

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

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