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

Answer key

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

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