← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

HTML and CSS lesson 17: Which CSS rule wins? · Set 701 · 40 questions
TalentJR

Code tip (Stronger first, then later): Strength: #id > .class > element. The stronger selector wins, wherever it is written. Equal strength: the later rule wins.

NameDateTime takenScore ___ / 40
  1. 1.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
  2. 2.⚖️ Which selector is the weakest? (a) an id selector (b) a class selector (c) an element selector
  3. 3.⚖️ What colour is the text of this element?
    <h2 class="note" id="top">Hi</h2>
    CSS:
    .note { color: yellow; }
    #top { color: green; }
    (a) red (b) yellow (c) white (d) green
  4. 4.⚖️ What colour is the text of this element?
    <p class="box" id="end">Hi</p>
    CSS:
    #end { color: yellow; }
    p { color: red; }
    .box { color: white; }
    (a) red (b) yellow (c) white (d) purple
  5. 5.⚖️ What colour is the text of this element?
    <h2 class="note" id="main">Hi</h2>
    CSS:
    #main { color: blue; }
    #main { color: red; }
    (a) yellow (b) purple (c) red (d) blue
  6. 6.⚖️ What colour is the text of this element?
    <p class="note" id="top">Hi</p>
    CSS:
    #top { color: green; }
    p { color: purple; }
    .note { color: orange; }
    (a) yellow (b) green (c) purple (d) orange
  7. 7.⚖️ What colour is the text of this element?
    <p class="big" id="intro">Hi</p>
    CSS:
    .big { color: blue; }
    #intro { color: orange; }
    p { color: yellow; }
    (a) blue (b) yellow (c) red (d) orange
  8. 8.⚖️ What colour is the text of this element?
    <h2 class="big" id="hero">Hi</h2>
    CSS:
    h2 { color: yellow; }
    #hero { color: purple; }
    .big { color: white; }
    (a) yellow (b) white (c) orange (d) purple
  9. 9.⚖️ What colour is the text of this element?
    <h2 class="box" id="end">Hi</h2>
    CSS:
    .box { color: red; }
    .box { color: yellow; }
    (a) black (b) green (c) red (d) yellow
  10. 10.⚖️ What colour is the text of this element?
    <p class="note" id="hero">Hi</p>
    CSS:
    .note { color: green; }
    p { color: red; }
    #hero { color: black; }
    (a) green (b) black (c) red (d) orange
  11. 11.⚖️ What colour is the text of this element?
    <p class="star" id="top">Hi</p>
    CSS:
    p { color: green; }
    #top { color: blue; }
    .star { color: orange; }
    (a) green (b) orange (c) white (d) blue
  12. 12.⚖️ What colour is the text of this element?
    <h1 class="note" id="end">Hi</h1>
    CSS:
    .note { color: yellow; }
    .note { color: red; }
    (a) yellow (b) red (c) orange (d) white
  13. 13.⚖️ What colour is the text of this element?
    <h1 class="star" id="end">Hi</h1>
    CSS:
    h1 { color: red; }
    .star { color: blue; }
    #end { color: black; }
    (a) blue (b) black (c) red (d) yellow
  14. 14.⚖️ What colour is the text of this element?
    <h1 class="star" id="logo">Hi</h1>
    CSS:
    .star { color: white; }
    h1 { color: black; }
    #logo { color: red; }
    (a) black (b) red (c) purple (d) white
  15. 15.⚖️ What colour is the text of this element?
    <h1 class="note" id="end">Hi</h1>
    CSS:
    .note { color: blue; }
    .note { color: green; }
    (a) green (b) orange (c) blue (d) red
  16. 16.⚖️ What colour is the text of this element?
    <h1 class="red" id="main">Hi</h1>
    CSS:
    h1 { color: blue; }
    h1 { color: black; }
    (a) black (b) blue (c) red (d) yellow
  17. 17.⚖️ What colour is the text of this element?
    <p class="big" id="end">Hi</p>
    CSS:
    .big { color: purple; }
    #end { color: red; }
    p { color: blue; }
    (a) blue (b) green (c) purple (d) red
  18. 18.⚖️ What colour is the text of this element?
    <h1 class="box" id="logo">Hi</h1>
    CSS:
    h1 { color: purple; }
    h1 { color: blue; }
    (a) green (b) blue (c) purple (d) yellow
  19. 19.⚖️ What colour is the text of this element?
    <h1 class="menu" id="logo">Hi</h1>
    CSS:
    #logo { color: blue; }
    .menu { color: black; }
    h1 { color: purple; }
    (a) purple (b) white (c) black (d) blue
  20. 20.⚖️ What colour is the text of this element?
    <h1 class="note" id="main">Hi</h1>
    CSS:
    #main { color: purple; }
    #main { color: orange; }
    (a) green (b) red (c) orange (d) purple
  21. 21.⚖️ What colour is the text of this element?
    <p class="red" id="logo">Hi</p>
    CSS:
    .red { color: red; }
    #logo { color: white; }
    p { color: purple; }
    (a) red (b) yellow (c) white (d) purple
  22. 22.⚖️ What colour is the text of this element?
    <p class="note" id="main">Hi</p>
    CSS:
    .note { color: blue; }
    .note { color: yellow; }
    (a) blue (b) white (c) yellow (d) black
  23. 23.⚖️ What colour is the text of this element?
    <p class="big" id="intro">Hi</p>
    CSS:
    .big { color: orange; }
    p { color: blue; }
    #intro { color: green; }
    (a) green (b) orange (c) blue (d) red
  24. 24.⚖️ What colour is the text of this element?
    <p class="menu" id="main">Hi</p>
    CSS:
    #main { color: green; }
    .menu { color: orange; }
    p { color: blue; }
    (a) green (b) yellow (c) orange (d) blue
  25. 25.⚖️ What colour is the text of this element?
    <h2 class="big" id="end">Hi</h2>
    CSS:
    .big { color: green; }
    .big { color: orange; }
    (a) purple (b) green (c) orange (d) yellow
  26. 26.⚖️ What colour is the text of this element?
    <h2 class="big" id="top">Hi</h2>
    CSS:
    .big { color: purple; }
    .big { color: black; }
    (a) blue (b) orange (c) black (d) purple
  27. 27.⚖️ What colour is the text of this element?
    <h2 class="star" id="end">Hi</h2>
    CSS:
    h2 { color: red; }
    #end { color: green; }
    .star { color: white; }
    (a) white (b) green (c) red (d) orange
  28. 28.⚖️ What colour is the text of this element?
    <h1 class="menu" id="main">Hi</h1>
    CSS:
    h1 { color: white; }
    h1 { color: orange; }
    (a) white (b) orange (c) purple (d) green
  29. 29.⚖️ What colour is the text of this element?
    <h2 class="box" id="hero">Hi</h2>
    CSS:
    h2 { color: white; }
    .box { color: yellow; }
    #hero { color: purple; }
    (a) white (b) yellow (c) red (d) purple
  30. 30.⚖️ What colour is the text of this element?
    <h1 class="big" id="top">Hi</h1>
    CSS:
    #top { color: red; }
    #top { color: yellow; }
    (a) yellow (b) black (c) red (d) white
  31. 31.⚖️ What colour is the text of this element?
    <h1 class="star" id="end">Hi</h1>
    CSS:
    h1 { color: green; }
    .star { color: purple; }
    (a) green (b) purple (c) white (d) red
  32. 32.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) neither (c) the shorter one (d) the later one
  33. 33.⚖️ What colour is the text of this element?
    <h1 class="star" id="main">Hi</h1>
    CSS:
    #main { color: yellow; }
    #main { color: green; }
    (a) green (b) yellow (c) blue (d) black
  34. 34.⚖️ What colour is the text of this element?
    <h2 class="note" id="hero">Hi</h2>
    CSS:
    h2 { color: green; }
    h2 { color: blue; }
    (a) yellow (b) black (c) blue (d) green
  35. 35.⚖️ What colour is the text of this element?
    <h2 class="star" id="top">Hi</h2>
    CSS:
    .star { color: red; }
    #top { color: yellow; }
    h2 { color: orange; }
    (a) yellow (b) blue (c) orange (d) red
  36. 36.⚖️ What colour is the text of this element?
    <h1 class="note" id="intro">Hi</h1>
    CSS:
    #intro { color: green; }
    #intro { color: red; }
    (a) green (b) red (c) white (d) black
  37. 37.⚖️ What colour is the text of this element?
    <p class="big" id="end">Hi</p>
    CSS:
    #end { color: blue; }
    #end { color: red; }
    (a) blue (b) green (c) yellow (d) red
  38. 38.⚖️ What colour is the text of this element?
    <p class="red" id="logo">Hi</p>
    CSS:
    p { color: red; }
    p { color: orange; }
    (a) purple (b) green (c) red (d) orange
  39. 39.⚖️ What colour is the text of this element?
    <p class="menu" id="hero">Hi</p>
    CSS:
    p { color: blue; }
    .menu { color: white; }
    (a) orange (b) red (c) blue (d) white
  40. 40.⚖️ What colour is the text of this element?
    <h1 class="star" id="top">Hi</h1>
    CSS:
    #top { color: black; }
    #top { color: white; }
    (a) black (b) white (c) yellow (d) blue

Answer key

  1. an id selector
  2. an element selector
  3. green
  4. yellow
  5. red
  6. green
  7. orange
  8. purple
  9. yellow
  10. black
  11. blue
  12. red
  13. black
  14. red
  15. green
  16. black
  17. red
  18. blue
  19. blue
  20. orange
  21. white
  22. yellow
  23. green
  24. green
  25. orange
  26. black
  27. green
  28. orange
  29. purple
  30. yellow
  31. purple
  32. the later one
  33. green
  34. blue
  35. yellow
  36. red
  37. red
  38. orange
  39. white
  40. white

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