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

Answer key

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

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