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

Answer key

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

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