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

Answer key

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

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