← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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