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

Answer key

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

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