← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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