← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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