← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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