← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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