← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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