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

Answer key

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

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