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

Answer key

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

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