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

Answer key

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

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