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

Answer key

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

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