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

Answer key

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

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