← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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