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

Answer key

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

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