← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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