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

Answer key

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

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