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

Answer key

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

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