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

Answer key

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

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