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

Answer key

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

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