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

Answer key

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

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