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

Answer key

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

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