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

Answer key

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

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