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

Answer key

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

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