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

Answer key

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

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