← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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