← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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