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

Answer key

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

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