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

Answer key

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

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