← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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