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

Answer key

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

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