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

Answer key

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

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