← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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