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

Answer key

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

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