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

Answer key

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

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