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

Answer key

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

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