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

Answer key

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

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