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

Answer key

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

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