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

Answer key

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

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