← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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