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

Answer key

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

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