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

Answer key

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

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