← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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