← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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