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

Answer key

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

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