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

Answer key

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

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