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

Answer key

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

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