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

Answer key

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

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