← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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