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

Answer key

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

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