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

Answer key

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

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