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

Answer key

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

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