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

Answer key

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

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