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

Answer key

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

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