← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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