← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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