← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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