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

Answer key

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

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