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

Answer key

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

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