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

Answer key

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

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