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

Answer key

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

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