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

Answer key

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

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