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

Answer key

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

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