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

Answer key

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

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