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

Answer key

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

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