← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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