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

Answer key

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

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