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

Answer key

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

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