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

Answer key

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

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