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

Answer key

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

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