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

Answer key

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

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