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

Answer key

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

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