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

Answer key

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

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