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

Answer key

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

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