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

Answer key

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

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