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

Answer key

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

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