← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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