← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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