← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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