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

Answer key

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

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