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

Answer key

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

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