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

Answer key

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

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