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

Answer key

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

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