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

Answer key

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

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